JWT Multi Auth无法与Laravel 5.7一起使用

时间:2018-11-28 12:24:01

标签: jwt laravel-5.7

先谢谢。
最近我在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);

0 个答案:

没有答案