the problem is about select user model
mamadza opened this issue · comments
Hi I use your package and I have a problem
assume I have two
'user' => [ 'identityClass' => 'app\models\User', ], 'admin' => [ 'class' => 'yii\web\User', 'identityClass' => 'app\models\Admin', ],
when I want to authenticate by jwt, it seems we have two request one for user and another one for admin
I don't need admin one, when I remove admin part from web.php the problem resolves
it seems it can't detect which user model it should use in AccessControll we define :
'user' => Yii::$app->admin,
but here we don't have anyone
You can provide the proper user component in the JwtHttpBearerAuth filter. This extends AuthMethod class and there is an option to set user
component, see https://github.com/yiisoft/yii2/blob/master/framework/filters/auth/AuthMethod.php#L30
You could switch it to your admin
to be used for him.
Thank you bizley
$behaviors['authenticator'] = [ 'class' => JwtHttpBearerAuth::class, 'user' => Yii::$app->user; ];
is it correct way?
Yes.