dev-master
9999999-devuser extension for Yii2
MIT
The Requires
by Maxim Kozhin
user extension yii2
1.0.0
1.0.0.0user extension for Yii2
MIT
The Requires
by Maxim Kozhin
user extension yii2
user extension for Yii2
User Extension for Yii2, (*1)
add to your 'require' section in file 'composer.json', (*2)
"require": { ... "maximkozhin/yii2-user": "*" },
or run command, (*3)
$ composer require maximkozhin/yii2-user
run migration:, (*4)
yii migrate/up --migrationPath=@vendor/maximkozhin/yii2-user/migrations
to revert migration run:, (*5)
yii migrate/down --migrationPath=@vendor/maximkozhin/yii2-user/migrations
Copy files into 'your-repo' directory., (*6)
after add into components, (*7)
... 'componetns' => [ ... 'user' => [ 'class' => 'maximkozhin\user\components\User', 'identityClass' => 'maximkozhin\user\models\User', 'loginUrl' => 'url/alias/to/login' 'logoutUrl' => 'url/alias/to/logout' ], ... ] ...
Into your code you may use, (*8)
User is guest, (*9)
Yii::$app->user->is('guest');
User is logged in, (*10)
Yii::$app->user->is('user');
To create another role typo an alias of role and name of role., (*11)
$alias = 'admin'; \maximkozhin\user\models\Role::add($alias, 'Администратор');
Add this role for user, (*12)
/** @var \maximkozhin\user\models\User $user*/ $user->addRole($alias);
after that you may check user role, (*13)
Yii::$app->user->is('admin'); or $user->is('admin');
to delete role for user, (*14)
/** @var \maximkozhin\user\models\User $user*/ $user->deleteRole($alias);
... 'modules' => [ ... 'user-module-name' => [ 'class' => 'maximkozhin\user\modules\user\Module', ], ... ], ...
user extension for Yii2
MIT
user extension yii2
user extension for Yii2
MIT
user extension yii2