worstinme/yii2-user

Yii2用户认证模块

安装次数: 1,053

依赖项: 0

建议者: 0

安全: 0

星标: 1

关注者: 3

分支: 1

开放性问题: 0

类型:yii2-extension

1.0.2 2017-02-07 08:51 UTC

This package is not auto-updated.

Last update: 2024-09-14 18:20:29 UTC


README

开发中。使用风险自担

使用Uikit框架设计的用户认证/数据库-RBAC/认证客户端模块。

Latest Stable Version Total Downloads

安装

安装此扩展的首选方式是通过composer

运行以下命令:

php composer.phar require --prefer-dist worstinme/yii2-user

或者

"worstinme/yii2-user": "^1.0.0"

将以下内容添加到您的composer.json文件的require部分。

所需配置

'modules' => [
    'user' => [
        'class' => 'worstinme\user\Module',
    ],
    'useradmin' => [
        'class' => 'worstinme\user\backend\Module',
    ],
    ....
 ],
'components' => [
	'user' => [
        'class'=>'worstinme\user\User',
        'identityClass' => 'worstinme\user\models\User',
        'enableAutoLogin' => true,
        'loginUrl'=>['/user/default/login'],
    ],
    'authClientCollection' => [
        'class' => 'yii\authclient\Collection',
        'clients' => [
            'google' => [
                'class' => 'yii\authclient\clients\GoogleOpenId'
            ],
            'facebook' => [
                'class' => 'yii\authclient\clients\Facebook',
                'clientId' => 'facebook_client_id',
                'clientSecret' => 'facebook_client_secret',
            ],
            // etc.
        ],
    ]
    //	...
]

RBAC配置

到web.php & console.php组件部分

    'authManager' => [
            'class' => 'yii\rbac\DbManager',
    ],
]

& 迁移文件

$ yii migrate --migrationPath=@yii/rbac/migrations/

然后,使用迁移创建用户表 & 默认用户管理员:administrator(具有管理员角色,别忘了更改默认密码)。

$ yii migrate --migrationPath=@worstinme/user/migrations/