Esempio n. 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);
 }
 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;
 }
 public function testDelete()
 {
     $em = $this->createEntityManagerMock();
     $token = new Token();
     $em->expects($this->once())->method('remove')->with($token);
     $em->expects($this->once())->method('flush');
     $manipulator = new TokenManipulator($em, self::$DI['app']['random.low'], self::$DI['app']['repo.tokens'], self::$DI['app']['tmp.download.path']);
     $manipulator->delete($token);
 }