dev-master
9999999-devYii 2 user authentiction module
GPL-3.0
The Requires
by Mirage Studio TH
extension yii2
0.0.1
0.0.1.0Yii 2 user authentiction module
GPL-3.0
The Requires
by Mirage Studio TH
extension yii2
Yii 2 user authentiction module
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)
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 ], ... ],
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]
$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
Yii 2 user authentiction module
GPL-3.0
extension yii2
Yii 2 user authentiction module
GPL-3.0
extension yii2