コード例 #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;
 }
コード例 #3
0
 public function testRemoveExpiredToken()
 {
     $this->assertCount(4, self::$DI['app']['repo.tokens']->findAll());
     $manipulator = new TokenManipulator(self::$DI['app']['orm.em'], self::$DI['app']['random.low'], self::$DI['app']['repo.tokens'], self::$DI['app']['tmp.download.path'], self::$DI['app']['tmp.download.path']);
     $manipulator->removeExpiredTokens();
     $this->assertCount(3, self::$DI['app']['repo.tokens']->findAll());
 }