The reference answer https://stackoverflow.com/questions/35254678/multiple-user-identity-in-config-yii2
Database table user account table (background), member (front desk member table)
Configuration file. The main components in the PHP
'user'=& gt;
'identityClass=& gt; 'common \ models \ User',
'enableAutoLogin=& gt; True,
'identityCookie=& gt; [' name '=& gt;' _identity - user ', 'httpOnly=& gt; true],
'idParam=& gt; '__id - user'
],
'member'=& gt;
'class=& gt; 'yii \ web \ User',
'identityClass=& gt; 'common \ models \ Member',
'enableAutoLogin=& gt; True,
'identityCookie=& gt; [' name '=& gt;' _identity - member ', 'httpOnly=& gt; true],
'idParam=& gt; '__id - member'
],
Interface call
Bearer token - * * *
If the bearer is member is an error in the table
{
"Name" : "Unauthorized",
"Message" : "Your request was made with invalid credentials.",
"Code" : 0,
"Status" : 401,
"Type" : "yii \ \ web \ \ UnauthorizedHttpException"
}
Use the table bearer
Can normal visit
This return is empty Yii: : $app - & gt; Member - & gt; Identity
The Yii: : $app - & gt; Member has a return objects
I want to know if the same API interface, to call the front desk and the background, and according to the user and member two tables provide token, to judge is the front desk users or background, how to operate, is there a better way of thinking,
CodePudding user response:
Create a subclass inherits HttpBearerAuth ah, add a Controller behavior point to this subclassCodePudding user response:
Trouble ask is how to deal with your side, how to configure the two tables of token validation