先谢谢。
最近我在laravel5.7中安装了jwt。但多重身份验证无法正常工作。
我的代码看起来像这样。
$credentials = $request->only('email', 'password');
Config::set('jwt.user', \App\Admin::class);
Config::set('auth.providers.users.model', \App\Admin::class);
dd(JWTAuth::attempt($credentials));
$token = null;
try {
if (!$token = JWTAuth::attempt($credentials)) {
return response()->json([
'meta' => [
'message' => 'invalid_email_or_password',
'status_code' => 422,
'status' => false,
],
], 422);
}
} catch (JWTAuthException $e) {
return response()->json([
'meta' => [
'message' => 'failed_to_create_token',
'status_code' => 422,
'status' => false,
],
], 422);
}
// $userDetails = Admin::where()
$this->apiAuth = app('App\Admin');
return response()->json([
'meta' => [
'message' => 'Admin user is loggedin',
'status_code' => 200,
'status' => true,
],
],200);