killbond / yii2-auth
Yii 2 用户认证与基于角色的访问控制(RBAC)模块
0.5.3
2015-01-09 15:21 UTC
Requires
- php: >=5.4.0
- yiisoft/yii2: *
- yiisoft/yii2-bootstrap: *
- yiisoft/yii2-composer: *
- yiisoft/yii2-swiftmailer: *
This package is not auto-updated.
Last update: 2024-09-28 17:12:31 UTC
README
认证模块是一个灵活的用户注册、认证和RBAC模块,适用于Yii2。它为您的Yii2网站提供用户认证、注册和RBAC支持。
安装
安装此扩展的首选方式是通过 composer。
运行以下命令之一:
$ php composer.phar require killbond/yii2-auth "*"
或者将以下内容添加到您的 composer.json
文件的 require 部分:
"killbond/yii2-auth": "*"
使用方法
安装扩展后,修改您的应用程序配置以包含
return [ 'modules' => [ ... 'auth' => [ 'class' => 'auth\Module', 'layout' => '//homepage', // Layout when not logged in yet 'layoutLogged' => '//main', // Layout for logged in users 'attemptsBeforeCaptcha' => 3, // Optional 'supportEmail' => 'support@mydomain.com', // Email for notifications 'passwordResetTokenExpire' => 3600, // Seconds for token expiration 'superAdmins' => ['admin'], // SuperAdmin users 'tableMap' => [ // Optional, but if defined, all must be declared 'User' => 'user', 'UserStatus' => 'user_status', 'ProfileFieldValue' => 'profile_field_value', 'ProfileField' => 'profile_field', 'ProfileFieldType' => 'profile_field_type', ], ], ... ], ... 'components' => [ ... 'authManager' => [ 'class' => '\yii\rbac\DbManager', 'ruleTable' => 'AuthRule', // Optional 'itemTable' => 'AuthItem', // Optional 'itemChildTable' => 'AuthItemChild', // Optional 'assignmentTable' => 'AuthAssignment', // Optional ], 'user' => [ 'class' => 'auth\components\User', 'identityClass' => 'auth\models\User', // or replace to your custom identityClass 'enableAutoLogin' => true, ], ... ] ];
并运行迁移
$ php yii migrate/up --migrationPath=@auth/migrations
许可协议
认证模块以BSD-3许可协议发布。有关详细信息,请参阅附带文件 LICENSE.md
。
#安装
./yii migrate/up --migrationPath=@auth/migrations
URLs
- 登录:
yourhost/auth/default/login
- 登出:
yourhost/auth/default/logout
- 注册:
yourhost/auth/default/signup
- 重置密码:
yourhost/auth/default/reset-password
- 用户管理:
yourhost/auth/user/index
- 用户资料:
yourhost/auth/profile/view