PHP code example of sandbox / passwordrecovery

1. Go to this page and download the library: Download sandbox/passwordrecovery library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

sandbox / passwordrecovery example snippets


extensions:
    passwordRecovery: Sandbox\PasswordRecovery\DI\PasswordRecoveryExtension

passwordRecovery:
    passwordRecovery:
    sender: "[email protected]"
    subject: "Obnova hesla"
    submitButton: "Obnovit heslo"
    validatorMessage: "Prosím vložte validní heslo."
    equalPasswordMessage: "Hesla se musí shodovat."
    emptyPasswordMessage: "Heslo musí obsahovat alespoň %d znaků"
    minimalPasswordLength: 6
    expirationTime: 45 #minute, max 59
    errorMessage: "Odkaz pro obnovu hesla se nepodařilo odeslat. Zkuste to prosím znovu."
    mailer: @mail.mailer
    token: @Sandbox\PasswordRecovery\TokenManagerInterface

/**
 * @return \Nette\Application\UI\Form
*/
protected function createComponentRecovery() {
	$control = $this->passwordRecovery->createDialog();
	$control->getResetForm()->onSuccess[] = function(Form $form) {
		$this->flashMessage('Odkaz pro obnovu hesla byl odeslán na Váš email ' . $form->getValues()['email'] . ".");
		$this->redrawControl('recoveryForm');
	};

	$control->getResetForm()->onError[] = function() {
		$this->redrawControl('recoveryForm');
	};

	$control->getNewPasswordForm()->onSuccess[] = function() {
		$this->flashMessage('Heslo bylo úspěšně nastaveno. Pokračujte na přihlašovací obrazovku.');
		if ($this->isAjax()) {
           $this->redrawControl('recoveryForm');
        } else {
           $this->redirect('Home:default');
        }
	};

	$control->getNewPasswordForm()->onError[] = function() {
		if ($this->isAjax()) {
           $this->redrawControl('recoveryForm');
        } else {
           $this->redirect('Home:default');
        }
	};

	return $control;
}

{snippet recoveryForm}
	<div n:foreach="$flashes as $flash" class="alert alert-success">{$flash->message}</div>
	{if count($flashes) == 0}
		{control recovery}
	{/if}
{/snippet}