geniv/nette-identity-login

Identity login extension for Nette Framework

v1.1.4 2019-05-24 16:54 UTC

This package is auto-updated.

Last update: 2024-10-25 08:02:44 UTC


README

Installation

$ composer require geniv/nette-identity-login

or

"geniv/nette-identity-login": "^1.1"

require:

"php": ">=7.0",
"nette/application": ">=2.4",
"nette/di": ">=2.4",
"nette/security": ">=2.4",
"nette/utils": ">=2.4",
"geniv/nette-general-form": ">=1.0"

Include in application

neon configure:

# identity login
identityLogin:
#   autowired: true
#   formContainer: Identity\Login\FormContainer

neon configure extension:

extensions:
    identityLogin: Identity\Login\Bridges\Nette\Extension

presenters:

protected function createComponentIdentityLogin(ILoginForm $loginForm): ILoginForm
{
    //$loginForm->setTemplatePath(__DIR__ . '/templates/LoginForm.latte');
    $loginForm->onLoggedIn[] = function (User $user) {
        $this->flashMessage('Login!', 'info');
    };
    $loginForm->onAfterLoggedIn[] = function (User $user) {
        $this->redirect('this');
    };
    $loginForm->onLoggedInException[] = function (AuthenticationException $e) {
        $this->flashMessage('Login exception! ' . $e->getMessage(), 'danger');
    };
    $loginForm->onLoggedOut[] = function (User $user) {
        $this->flashMessage('Logout!', 'info');
    };
    $loginForm->onAfterLoggedOut[] = function (User $user) {
        $this->redirect('this');
    };
    return $loginForm;
}

usage:

    {if !$user->isLoggedIn()}
        {control identityLogin}
    {else}
        <a n:href="identityLogin:Out!">Logout</a>
    {/if}