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

lloy0076 picture lloy0076  路  3Comments

mihailo-misic picture mihailo-misic  路  3Comments

phamduong picture phamduong  路  3Comments

NaelsonBrasil picture NaelsonBrasil  路  3Comments

kofi1995 picture kofi1995  路  3Comments