簡體   English   中英

使用Customer表進行基於角色的訪問控制,而不是yii2中的用戶

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

我想在yii2中使用表login_info而不是表user在前端部分中創建的成員活動(不在后端部分中)。 我在表login_info上也有角色,例如:health-post,hospital,fchv等,不能從user_id進行管理,而可以從user_name進行管理。 您在yii2中有任何想法嗎?

如果您只想更改表名(表的模式類似於yii用戶表),則可以輕松地(重新)定義函數tableName

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';
    }
}

但是,如果要基於特定功能定義User組件,則應創建一個新的正確的User類,以實現Identity接口。您可以看到身份驗證安全性指南用戶界面yii用戶類,以供參考和示例。

不是簡單的工作。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM