我尝试通过教程https://blog.logrocket.com/implementing-jwt-authentication-laravel-9/使用php-开放源码保护程序/jwt-auth。
它可以正常工作,但我在注销方面有一些问题。
Auth::logout();当我注销,然后尝试调用我的测试方法时,它使用旧令牌。
class SubjectController extends Controller
{
public function __construct()
{
$this->middleware('auth:api');
}
public function show($id)
{
$subject = Subject::find($id);
return response(json_encode($subject))
->header('Content-Type','application/json');
}
}发布于 2022-06-26 05:14:08
核对文件:https://laravel-jwt-auth.readthedocs.io/en/latest/auth-guard/
logout()将用户注销--这将使当前令牌失效,并取消身份验证用户的设置。
auth()->logout();
// Pass true to force the token to be blacklisted "forever"
auth()->logout(true);https://stackoverflow.com/questions/72757021
复制相似问题