Laravel 9 JWT logout problem php-open-source-saver/jwt-auth
P粉809110129
P粉809110129 2023-12-12 08:38:04
0
1
446

I tried using php-open-source-saver/jwt-auth via tutorial https://blog.logrocket.com/implementing-jwt-authentication-laravel-9/

It works fine but I have some issues when logging out.

Auth::logout();

When I log out and try to call my test method, it uses the old token.

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');
    }
}


P粉809110129
P粉809110129

reply all(1)
P粉638343995

Check the documentation: https://laravel-jwt-auth .readthedocs.io/en/latest/auth-guard/

logout()

Log out the user - This will invalidate the current token and unprovision the authenticated user.

auth()->logout();

// Pass true to force the token to be blacklisted "forever"
auth()->logout(true);
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!