Пример #1
0
 /**
  * Returns user id or false if unable to authenticate
  * @param User $user
  * @param array $params
  * @return mixed
  */
 public function authenticate(User $user, array $params = [])
 {
     if ($user->isEnabled() && password_verify($params['password'], $user->getPassword())) {
         return $user->getId();
     }
     return false;
 }
Пример #2
0
 public function requestPasswordResetTokenByUser(User $user)
 {
     $this->cleanResetTokens = true;
     if ($user && $user->isEnabled()) {
         $expires = isset($this->container['user.password_reset_token_expire']) ? new \DateTime($this->container['user.password_reset_token_expire']) : new \DateTime('+24 hours');
         $token = (new PasswordResetToken())->setExpires($expires)->setUser($user);
         $this->getEntityManager()->persist($token);
         $this->getEntityManager()->flush();
         return $token;
     } else {
         throw new \Exception(self::ERROR_USER_DISABLED);
     }
 }