1. Go to this page and download the library: Download geniv/nette-authenticator 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/ */
geniv / nette-authenticator example snippets
use Authenticator\LoginForm;
protected function createComponentLoginForm(LoginForm $loginForm)
{
//$loginForm->setTemplatePath(__DIR__ . '/templates/LoginForm.latte');
// callback from $loginForm (support redirect)
$loginForm->onLoggedIn[] = function (User $user) {
$this->flashMessage('Login!', 'info');
$this->redirect('this');
};
$loginForm->onLoggedInException[] = function (AuthenticationException $e) {
$this->flashMessage('Login exception! ' . $e->getMessage(), 'danger');
};
$loginForm->onLoggedOut[] = function (User $user) {
$this->flashMessage('Logout!', 'info');
$this->redirect('this');
};
//OR
// callback from $this->user (don't support redirect)
$this->user->onLoggedIn[] = function (User $user) {
$this->flashMessage('Login!', 'info');
};
$this->user->onLoggedOut[] = function (User $user) {
$this->flashMessage('Logout!', 'info');
};
return $loginForm;
}