robregonm / yii2-auth
此包已被废弃,不再维护。未建议替代包。
                                        
                    
                    Yii 2 用户认证 & 基于角色的访问控制(RBAC)模块
    0.6.2
    2015-06-02 20:44 UTC
Requires
- php: >=5.4.0
- yiisoft/yii2: *
- yiisoft/yii2-bootstrap: *
- yiisoft/yii2-composer: *
- yiisoft/yii2-swiftmailer: *
README
认证模块是适用于 Yii2 的灵活的用户注册、认证和 RBAC 模块。它为您的 Yii2 网站提供用户认证、注册和 RBAC 支持。
安装
安装此扩展的首选方式是通过 composer。
运行以下命令之一:
$ php composer.phar require robregonm/yii2-auth "*"
或者将以下内容添加到您的 composer.json 文件的 require 部分中:
"robregonm/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 'signupWithEmailOnly' => false, // false = signup with username + email, true = only email signup '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