Jwt-auth: Logout??!?!?!?!?!?!?!

Created on 11 Jan 2018  路  3Comments  路  Source: tymondesigns/jwt-auth

After 2 DAYS i can not understand how to do a logout method!!!

    public function logout(Request $request)
        {
            $user = JWTAuth::parseToken()->toUser();
            JWTAuth::invalidate(JWTAuth::parseToken());
            $authuser=Auth::user();
            $user2 = JWTAuth::parseToken()->toUser();
            return response()->json([$user,$authuser,$user2],200);

or get always a user autenticated or get a exception in all test!?but, the documentation don't say nothig about logout method!!!!

Most helpful comment

$token=JWTAuth::getToken();JWTAuth::invalidate($token);

All 3 comments

$token=JWTAuth::getToken();JWTAuth::invalidate($token);

You may want the extra security of invalidating the token on the server, but for many (simple) applications, removing the token from the client will effectively logout the user. In my apps, that usually looks something like this in Javascript: localStorage.removeItem('auth_token'); replacing "auth_token" with whatever variable you're using.

Perhaps you should look at this document. http://jwt-auth.readthedocs.io/en/develop/auth-guard/

Was this page helpful?
0 / 5 - 0 ratings

Related issues

therealmjk picture therealmjk  路  3Comments

gamelife1314 picture gamelife1314  路  3Comments

loic-lopez picture loic-lopez  路  3Comments

mihailo-misic picture mihailo-misic  路  3Comments

agneshoving picture agneshoving  路  3Comments