예제 #1
0
 public function formSucceeded(Form $form)
 {
     try {
         $p = $this->getPresenter();
         $values = $form->getValues();
         $this->userRepository->updatePassword($this->item, $values->password, true);
         $p->flashMessage($this->translator->translate('locale.sign.password_changed_sign_in'), FlashType::INFO);
     } catch (PossibleUniqueKeyDuplicationException $e) {
         $this->addFormError($form, $e);
     } catch (\PDOException $e) {
         $this->addFormError($form, $e, $this->translator->translate('locale.error.occurred'));
     }
     $p->redirect(':Front:Homepage:default');
 }
예제 #2
0
 /**
  * @throws Nette\Security\AuthenticationException
  * @return Nette\Security\Identity
  */
 public function authenticate(array $credentials)
 {
     list($email, $password) = $credentials;
     $user = $this->userRepository->getByEmail($email);
     if (!$user) {
         throw new Nette\Security\AuthenticationException($this->translator->translate('locale.sign.incorrect_email'), self::IDENTITY_NOT_FOUND);
     } elseif (!$user->isAuthenticated) {
         throw new Nette\Security\AuthenticationException($this->translator->translate('locale.sign.authentication_waiting'), self::NOT_APPROVED);
     } elseif (!Passwords::verify($password . $user->salt, $user->password)) {
         throw new Nette\Security\AuthenticationException($this->translator->translate('locale.sign.incorrect_password'), self::INVALID_CREDENTIAL);
     } elseif (Passwords::needsRehash($user->password)) {
         $this->userRepository->updatePassword($user, $user->password);
     }
     return $this->updateIdentity($user);
 }