Answer the question
In order to leave comments, you need to log in
How to set a custom identity class for each module in Yii2?
Good afternoon
I have two RestAPI modules api1, api2
and each has its own authorization model.
How to make it so that when requesting to the api, each module uses its own authorization model to find the user by the token?
Answer the question
In order to leave comments, you need to log in
You are strange. Why do you need such a garden?
Similar to how you do it in the main app:
'user' => [
'identityClass' => 'common\models\User',
'loginUrl' => '/site/login',
'identityCookie' => [
'name' => '_identity-frontend',
],
],
'modules' => [
'api1' => [
'class' => 'api\modules\Api1',
'components' => [
'user' => [
'identityClass' => 'common\models\Api1User',
'loginUrl' => '/site/login',
'identityCookie' => [
'name' => '_identity-api1',
],
],
]
],
'api2' => [
'class' => 'api\modules\Api2',
'components' => [
'user' => [
'identityClass' => 'common\models\Api2User',
'loginUrl' => '/site/login',
'identityCookie' => [
'name' => '_identity-api2',
],
],
]
],
]
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question