我已经在自定义表中使用JWT创建了一个身份验证。身份验证工作很好,我能够登录和令牌是成功生成的。问题是无法从自定义表生成的TOKEN中获取'id'等信息。
$token = $request->header('Authorization');
$user = JWTAuth::toUser($token);
return $user;
返回的信息来自'user'表,而不是来自用于jwt身份验证的自定义表。我的配置看起来像
'providers' => [
'users' => [
'driver' => 'eloquent',
'model' => AppModelsUser::class,
],
'partners_credentials' => [
'driver' => 'eloquent',
'table' => 'partners_credentials',
'model' => AppModelsPartnerCredentials::class,
],
],
警卫
'guards' => [
'web' => [
'driver' => 'session',
'provider' => 'users',
],
'partners_credentials' => [
'driver' => 'session',
'provider' => 'partners_credentials',
'hash' => false,
],
],
我在这里错过了什么
试试这个
$user = JWTAuth::user();