Ejemplo n.º 1
0
 /**
  * Check Nickname availability
  *
  * @param string $nickname
  * @return bool
  */
 private function isNicknameAvailable($nickname)
 {
     try {
         $this->facade->findByLogin($nickname);
         throw new InvalidInputException(_g('This Nickname is already taken'));
     } catch (UserExceptionInterface $e) {
         return true;
     }
 }
Ejemplo n.º 2
0
 /**
  * Authenticate the User with credentials
  *
  * @param string $login
  * @param string $password
  * @param bool   $remember
  * @throws UserExceptionInterface
  */
 public function authenticate($login, $password, $remember = false)
 {
     try {
         // Ищем юзера в базе данных по Логину
         $user = $this->facade->findByLogin($login);
         // Если юзер найден, проверяем пароль
         if (!$user->checkPassword($password)) {
             //TODO: Внедрить защиту от подбора пароля
             throw new WrongPasswordException('Password does not match');
         }
     } catch (UserExceptionInterface $e) {
         throw $e;
     }
     $this->checkToken($user);
     $this->writeSession($user);
     $this->writeCookie($user, $remember);
     Identification::updateAttributes($user, $this->request);
     $this->facade->setUser($user);
     $user->save();
 }