Hi, in my application I have clients in a model called UserClient and backoffice clients in the UserAdmin model. In config/web.php I do this:
/*'user' => [
'identityClass' => 'app\models\User',
'enableAutoLogin' => true,
],*/
'userClient' => [
'class'=>'yii\web\User',
'identityClass' => 'app\modules\customers\models\UserClient',
'enableAutoLogin' => true,
'loginUrl'=>'/customers/user/login',
'returnUrl'=>'/customers/customer/index',
],
'userAdmin' => [
'class'=>'yii\web\User',
'identityClass' => 'app\modules\backoffice\models\UserAdmin',
'enableAutoLogin' => true,
'loginUrl'=>'/backoffice/user/login',
'returnUrl'=>'/backoffice/user/index',
],
But, when I login in one and next I login in the other, the second one overwrites the first.
In UserController in customers module, I have this:
public function behaviors()
{
return [
'access' => [
'user' => 'userAdmin',
'class' => AccessControl::className(),
'only' => ['logout','index'],
'rules' => [
[
'allow' => true,
'roles' => ['@'],
],
],
],
'verbs' => [
'class' => VerbFilter::className(),
'actions' => [
'logout' => ['post'],
],
],
];
}
In UserController in backoffice module, I have this:
public function behaviors()
{
return [
'access' => [
'user' => 'userClient',
'class' => AccessControl::className(),
'only' => ['logout'],
'rules' => [
[
'allow' => true,
'roles' => ['@'],
],
],
],
'verbs' => [
'class' => VerbFilter::className(),
'actions' => [
'logout' => ['post'],
],
],
];
}
Somebody can help me? It’s possible have 2 access areas for 2 kind of users of different models?
Note: I am using Yii 2.0.3 (simple template)
Thanks!