示例#1
0
 public function attempt($username, $password)
 {
     $result = \Core\Storage::container()->get_storage($this->_table)->fetch(array('filter' => new \Core\Filter($this->_user_field, $username)))->{0};
     if (!$result) {
         throw new InvalidUserError();
     }
     try {
         $hasher = Hasher::create()->check($password, $result[$this->_password_field]);
         $this->_set_session($result['id'], $result);
     } catch (HashMismatch $e) {
         throw new IncorrectPasswordError();
     }
 }