2017 © Pedro Peláez
 

yii2-extension yii2-user

Yii 2 user authentiction module

image

miragesoft/yii2-user

Yii 2 user authentiction module

  • Monday, May 23, 2016
  • by mirage
  • Repository
  • 1 Watchers
  • 0 Stars
  • 11 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

yii2-user

Installation

The preferred way to install this extension is through composer., (*1)

Either run, (*2)

composer require miragesoft/yii2-user "dev-master"

or add, (*3)

"miragesoft/yii2-user": "dev-master"

to the require section of your composer.json file., (*4)

Usage

Once the extension is installed, simply use it in your code by :, (*5)

Config, (*6)

    'modules' => [
        ...
        'user' => [
            'class' => 'mirage\user\UserModule',
            'userUploadDir' => '@webroot/uploads/user', //base user upload directory
            'admins' => ['admin', 'mirage'], //Username for CRUD user 
        ],
        ...
    ],

List of available actions

  • /user/regist/signup Displays registration form
  • /user/auth/login Displays login form
  • /user/auth/logout Logs the user out (available only via POST method)
  • /user/auth/request-password-reset Displays request password reset form
  • /user/auth/reset-password Displays reset password form
  • /user/settings/profile Displays profile settings form
  • /user/settings/account Displays account settings form
  • /user/settings/change-password Displays change password settings form
  • /user/admin/index Displays user management interface

Example of menu

You can add links to registration, login and logout as follows:, (*7)

Yii::$app->user->isGuest ?
    ['label' => 'Sign in', 'url' => ['/user/auth/login']] :
    ['label' => 'Sign out (' . Yii::$app->user->identity->username . ')',
        'url' => ['/user/auth/logout'],
        'linkOptions' => ['data-method' => 'post']],
['label' => 'Register', 'url' => ['/user/regist/signup'], 'visible' => Yii::$app->user->isGuest]

Another modules call user information

$userObj = new $this->userModuleClass(['moduleId' => 'user']);
$userApi = (object)['data'=>$userObj->userData(), 'info'=>$userObj->userInfo()];
print_r($userApi);
echo '<hr />';
echo 'Fullname: '.$userApi->info->fullname;

Example Result, (*8)

stdClass Object
(
    [data] => stdClass Object
        (
            [id] => 1
            [username] => admin
            [created_at] => 1463562063
            [updated_at] => 1463562063
            [firstname] => Mirage
            [lastname] => Studio
            [fullname] => Mirage Studio
            [avatar] => avatar-img.jpg
            [cover] => 
            [bio] => 
            [data] => 
            [roles] => Array
                (
                )

        )

    [info] => stdClass Object
        (
            [id] => 1
            [username] => admin
            [created_at] => 1463562063
            [updated_at] => 1463562063
            [firstname] => Mirage
            [lastname] => Studio
            [fullname] => Mirage Studio
            [avatar] => /uploads/user/1/avatar/avatar-img.jpg
            [cover] => /assets/c5f36f99/images/default-cover.jpg
            [bio] => Not set
            [data] => Not set
            [roles] => Array
                (
                    [0] => stdClass Object
                        (
                            [name] => 
                        )

                )

        )

)



Fullname: Mirage Studio

The Versions

23/05 2016

dev-master

9999999-dev

Yii 2 user authentiction module

  Sources   Download

GPL-3.0

The Requires

 

by Mirage Studio TH

extension yii2

23/05 2016

0.0.1

0.0.1.0

Yii 2 user authentiction module

  Sources   Download

GPL-3.0

The Requires

 

by Mirage Studio TH

extension yii2