vim/user-auth

There is no license information available for the latest version (1.0.0) of this package.

UserAuth module for zend framework 3

1.0.0 2018-01-21 10:02 UTC

README

Module for Zend Framework 3.

Installation

Installation of this module uses composer. For composer documentation, please refer to getcomposer.org.

composer require vim/user-auth

Register Vim\UserAuth in config/modules.config.php:

<?php
return [
    'Vim\UserAuth',
];

Register Entity:

Example

<?php
/** @var \Vim\UserAuth\Service\AuthService $authService */
$authService = $container->get(\Vim\UserAuth\Service\AuthService::class);

//authenticate
$authService->authenticate('test@test.ru', 'some_password');

//logout
$authService->clearAuthenticate();

//check if the user is authorized
$authService->isAuthorized();

//get authorized user identity
$authService->getIdentity();

Get current user:

<?php
/** @var \Vim\UserAuth\Service\CurrentUserService $currentUserService */
$currentUserService = $container->get(\Vim\UserAuth\Service\CurrentUserService::class);
$currentUserService->get();

You can use initializer for \Vim\UserAuth\Service\CurrentUserService.

To do this, register initializer in service manager config.

<?php
return [
    'service_manager' => [
        'initializers' => [
            \Vim\UserAuth\ServiceManager\Initializer\Service\CurrentUserServiceInitializer::class,
        ],
    ],
];

View Helper:

<?php
$this->currentUser();