multiple user identity in config Yii2

前端 未结 3 1270
盖世英雄少女心
盖世英雄少女心 2021-01-21 08:15

I developing a site with two different registrations, and I have 2 different table, Im using RbacDB, and in the web config in the components section I have user configuration, a

3条回答
  •  情歌与酒
    2021-01-21 08:42

    You have to create a web user class for the second identity

    namespace app\components;
    
    class UserTwo extends \yii\web\User{
    }
    

    than specify the class name in your config

    'user-two' => [
            'class'=> 'app\components\UserTwo'
            'identityClass' => 'app\models\SecondUser',
            'enableAutoLogin' => true,
        ],
    

提交回复
热议问题