public function forgottenPasswordFormSucceeded(Form $form, ArrayHash $values): void
	{
		$value = $values->usernameOrEmail;
		$user = $this->orm->users->getByUsername($value);
		if (!$user) {
			$user = $this->orm->users->getByEmail($value);
			if (!$user) {
				$form->addError('cms.user.incorrectUsernameOrEmail');
				$session = $this->getSession('cms/forgottenPassword');
				if (isset($session->count)) {
					$session->count++;
				} else {
					$session->setExpiration('1 hours');
					$session->count = 1;
				}
				$this->actionForgottenPassword();
				return;
			}
		}

		$hash = $this->hasher->hash(Random::generate());

		$session = $this->getSession('cms/restorePassword');
		$session->setExpiration('1 hours');
		$session->$hash = $user->email;

		$this->mailer->sendRestorePassword($user->email, $hash);
		$this->flashNotifier->info('cms.user.mailToRestorePasswordSent');
		$this->redirect(":{$this->module}:Sign:in");
	}
public function forgottenPasswordFormSucceeded(Form $form, ArrayHash $values): void
	{
		$value = $values->usernameOrEmail;
		$user = $this->orm->users->getByUsername($value);
		if (!$user) {
			$user = $this->orm->users->getByEmail($value);
			if (!$user) {
				$form->addError('cms.user.incorrectUsernameOrEmail');
				$session = $this->getSession('cms/forgottenPassword');
				if (isset($session->count)) {
					$session->count++;
				} else {
					$session->setExpiration('1 hours');
					$session->count = 1;
				}
				$this->actionForgottenPassword();
				return;
			}
		}

		$hash = $this->hasher->hash(Random::generate());

		$session = $this->getSession('cms/restorePassword');
		$session->setExpiration('1 hours');
		$session->$hash = $user->email;

		$this->mailer->sendRestorePassword($user->email, $hash);
		$this->flashNotifier->info('cms.user.mailToRestorePasswordSent');
		$this->redirect(":{$this->module}:Sign:in");
	}
public function forgottenPasswordFormSucceeded ( Form $ form , ArrayHash $ values ) : void { $ value = $ values -> usernameOrEmail ; $ user = $ this -> orm -> users -> getByUsername ( $ value ) ; if ( ! $ user ) { $ user = $ this -> orm -> users -> getByEmail ( $ value ) ; if ( ! $ user ) { $ form -> addError ( 'cms.user.incorrectUsernameOrEmail' ) ; $ session = $ this -> getSession ( 'cms/forgottenPassword' ) ; if ( isset ( $ session -> count ) ) { $ session -> count ++ ; } else { $ session -> setExpiration ( '1 hours' ) ; $ session -> count = 1 ; } $ this -> actionForgottenPassword ( ) ; return ; } } $ hash = $ this -> hasher -> hash ( Random :: generate ( ) ) ; $ session = $ this -> getSession ( 'cms/restorePassword' ) ; $ session -> setExpiration ( '1 hours' ) ; $ session -> $ hash = $ user -> email ; $ this -> mailer -> sendRestorePassword ( $ user -> email , $ hash ) ; $ this -> flashNotifier -> info ( 'cms.user.mailToRestorePasswordSent' ) ; $ this -> redirect ( ":{$this->module}:Sign:in" ) ; }
Zpracovani formulare pro zapomenute heslo
@param Form $form
@param ArrayHash $values
@throws AbortException
@throws \Nette\Application\UI\InvalidLinkException
Zpracovani formulare pro zapomenute heslo