Пример #1
0
 public function resetPassword($resetToken, $newPassword)
 {
     $token = $this->tokenRepository->findValidToken($resetToken);
     if ($token === null || $token->getType() != TokenManipulator::TYPE_PASSWORD) {
         $this->application->abort(401, 'A token is required');
     }
     $this->userManipulator->setPassword($token->getUser(), $newPassword);
     $this->tokenManipulator->delete($token);
 }
Пример #2
0
 public function unlockAccount($token)
 {
     $token = $this->tokenRepository->findValidToken($token);
     if (!$token) {
         throw new RegistrationException('Invalid token');
     }
     $user = $token->getUser();
     if (!$user->isMailLocked()) {
         throw new RegistrationException('Account is already unlocked, you can login.', RegistrationException::ACCOUNT_ALREADY_UNLOCKED);
     }
     $this->tokenManipulator->delete($token);
     $user->setMailLocked(false);
     return $user;
 }