2017 © Pedro Peláez
 

yii2-extension yii2-auth-module

Yii 2 User Authentication & Role Based Access Control (RBAC) Module

image

prawee/yii2-auth-module

Yii 2 User Authentication & Role Based Access Control (RBAC) Module

  • Friday, February 26, 2016
  • by prawee
  • Repository
  • 0 Watchers
  • 0 Stars
  • 22 Installations
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 4 Versions
  • 0 % Grown

The README.md

Yii2 Authentication.

Yii 2 User Authentication & Role Based Access Control (RBAC) Module, (*1)

Installation

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

Either run, (*3)

php composer.phar require --prefer-dist prawee/yii2-auth-module "*"

or add, (*4)

"prawee/yii2-auth-module": "*"

above file, (*5)

...
"repositories": [
        {
            "type": "git",
            "url": "https://bitbucket.org/prawee/yii2-auth-module.git"
        },
    ],
....

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

Usage

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

main.php
<?php
....
'modules'=>[
    'auth'=>[
        'class'=>'auth\Module',
        'tableMap'=>[
            'User'=>'user'
        ],
        'modal'=>true
    ],
],
'components'=>[
    'user'=>[
        //'identityClass' => 'auth\models\User',
        //'enableAutoLogin' => true,
        //'loginUrl'=>'auth/default/login',
        'class' => 'auth\components\User',
    ],
    'authManager' => [
        'class' => 'yii\rbac\DbManager',
    ],
],
....
?>
params.php
return [
    ...
    'icon-framework'=>'fa',
    ...
];
Login:              localhost/projectname/admin/auth/default/login
Logout:             localhost/projectname/admin/auth/default/logout
Signup:             localhost/projectname/admin/auth/default/signup
Reset Password:     localhost/projectname/admin/auth/resetpassword
Set Permission:     localhost/projectname/admin/auth/user
Manage Permission:  localhost/projectname/admin/auth/permission
Profile:            localhost/projectname/admin/auth/user/profile 

Rbac

in console config file main-local.php, (*8)

.....
'components'=>[
        'db' => [
            'class' => 'yii\db\Connection',
            'dsn' => 'mysql:host=127.0.0.1;dbname=teachdev',
            'username' => 'root',
            'password' => '',
            'charset' => 'utf8',
        ],
        'authManager' => [
            'class' => 'yii\rbac\DbManager',
        ],
    ]
....

Migrate Database

Using command. ( Linux ), (*9)

./yii migrate  --migrationPath=@vendor/yiisoft/yii2/rbac/migrations
./yii migrate  --migrationPath=@auth/migrations 
./yii migrate  --migrationPath=@auth/migrations/profile
./yii migrate  --migrationPath=@auth/migrations/api

Using command. (Windows), (*10)

yii migrate  --migrationPath=@vendor/yiisoft/yii2/rbac/migrations
yii migrate  --migrationPath=@auth/migrations 
yii migrate  --migrationPath=@auth/migrations/profile
yii migrate  --migrationPath=@auth/migrations/api

Initializing

1.Create all models, (*11)

localhost/your-project/gii/model

Table Name
*

Click Preview Button
Click Generate Button

2.Create admin\app\models\User model extends by common\models\User, (*12)

localhost/your-project/admin/gii/model

namespace admin\app\models;
use auth\models\User as CUser;
class User extends CUser{}

3.Create admin\app\models\UserSearch by localhost/your-project/admin/gii/crud, (*13)

Model Class
admin\app\models\User

Search Model Class
admin\app\models\UserSearch

Controller Class
admin\app\controllers\UserController

Click Preview Button

Action Unselect all
Check UserSearch only

Click Generate Button

History

branch 1.0.tpt, (*14)

The Versions

26/02 2016

dev-master

9999999-dev

Yii 2 User Authentication & Role Based Access Control (RBAC) Module

  Sources   Download

MIT

The Requires

 

extension yii2

20/02 2015

1.2.0

1.2.0.0

Yii 2 User Authentication & Role Based Access Control (RBAC) Module

  Sources   Download

MIT

The Requires

 

extension yii2

14/12 2014

1.1.0.x-dev

1.1.0.9999999-dev

Yii 2 User Authentication & Role Based Access Control (RBAC) Module

  Sources   Download

MIT

The Requires

 

extension yii2

02/10 2014

dev-1.0.tpt

dev-1.0.tpt

Yii 2 User Authentication & Role Based Access Control (RBAC) Module

  Sources   Download

MIT

The Requires

 

extension yii2