我正在为我的应用程序使用tymondesigns / jwt-auth软件包。我使用customClaims制作令牌。 这是登录代码:
$token_data = [
'iss' => new Issuer('AreteHCM'),
'iat' => new IssuedAt(Carbon::now()) ,
'exp' => new Expiration(Carbon::now()->addDays(1)),
'nbf' => new NotBefore(Carbon::now()),
'sub' => new Subject('AreteHCMS'),
'jti' => new JwtId('AreteHCM'),
'user_data' => $user->user,
'menu_access' => $menu_access,
'login_time' => Carbon::now(),
];
$customClaims = JWTFactory::customClaims($token_data);
$payload = JWTFactory::make($customClaims);
$token = JWTAuth::encode($payload)->get();
对于注销,我使令牌无效,因此用户注销后不能再使用令牌。
JWTAuth::invalidate(JWTAuth::getToken());
我正在使用Angular创建API(后端)和前端团队。一切进展顺利,直到用户注销并尝试再次登录。登录后,用户获得了新帐户,但是当他/她想要访问我的中间件时,总是拒绝该令牌,它表示该令牌已被列入黑名单。
这是我的中间件:
$token = JWTAuth::getToken();
$data = JWTAuth::getPayload($token)->toArray();
它总是显示错误:
The token has been blacklisted in file C:\xampp\htdocs\aretehcm\vendor\tymon\jwt-auth\src\Manager.php on line 109
我要处理的是:
我对JWT-API架构是否有误解? 预先感谢您的答复和答复。
答案 0 :(得分:0)
通过Google的快速搜索,我找到了这种解决方案: https://github.com/tymondesigns/jwt-auth/issues/983#issuecomment-275884324