Hi,
I’ve been developing an application to manage an affilate network and have faced a problem with setting the correct class for identity to check & log the user into the system . The problem is: In the webapp, there are at least two different user identities. Let’s say the first identity is “Account”, the second is “Partner”.
I do not know how to pick the desired identity up during loggin user into the app. The default identity index is “user”. I would like to set the proper index, let’s say “partner” while (or better, before) I am logging a partner or “account” while I am logging as an owner of account. I wouldn’t like to have the “user” configuration in the config because it’s not used (by me) in the webapp.
Right now I’ve a config file like below.
'user' => [
'identityClass' => 'app\models\Account',
'enableAutoLogin' => true,
'loginUrl' => null
],
'partner' => [
'class' => 'yii\web\User',
'identityClass' => 'app\models\Partner',
'enableAutoLogin' => true,
'loginUrl' => null
],
'account' => [
'class' => 'yii\web\User',
'identityClass' => 'app\models\Account',
'enableAutoLogin' => true,
'loginUrl' => null
],
The method that logs "account" into the system looks like below:
public function login()
{
if ($this->validate()) {
return Yii::$app->account->login($this->getUser(), $this->rememberMe ? 3600*24*30 : 0);
} else {
return false;
}
}
The method for loggin a "partner" is:
public function login()
{
if ($this->validate()) {
return Yii::$app->partner->login($this->getUser(), $this->rememberMe ? 3600*24*30 : 0);
} else {
return false;
}
}
I hope it’s clear what I want to achive (if not let me know).