简体   繁体   English

使用Customer表进行基于角色的访问控制,而不是yii2中的用户

[英]Use customer table for role based access control instead of user in yii2

I want to use table login_info instead of table user in yii2 to create member activities in frontend part that are not in the backend part. 我想在yii2中使用表login_info而不是表user在前端部分中创建的成员活动(不在后端部分中)。 Also I have roles at the table login_info like :health-post, hospital, fchv, etc, not can be managed from user_id but can manage from user_name . 我在表login_info上也有角色,例如:health-post,hospital,fchv等,不能从user_id进行管理,而可以从user_name进行管理。 Do you have in any idea in yii2. 您在yii2中有任何想法吗?

If you want change only the tablename (and the schema of the table is like the yii user table ) you can easily (re)define the function tableName in your 如果您只想更改表名(表的模式类似于yii用户表),则可以轻松地(重新)定义函数tableName

frontend\\models User.php eg: this way frontend \\ models User.php例如:这种方式

namespace frontend\models;

use yii\models\web\User as BaseUser;

class User extends BaseUser
{
    public static function tableName()
    {
        return  'yuor_table_user';
    }
}

But if you want define a your User component based on your specific features you should create a new proper User class that implement the Identity interface You can see the the authentication - security guide , the user interface and the yii user class for reference and sample 但是,如果要基于特定功能定义User组件,则应创建一个新的正确的User类,以实现Identity接口。您可以看到身份验证安全性指南用户界面yii用户类,以供参考和示例。

Is not a simple job. 不是简单的工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM