2

First of all, i am still new to django rest framework jwt so pls excuse my stupidity if im wrong.

Im wondering about how to create a logout function for jwt as when user want to logout and switch account, they will need this function.

Based on the what i seen in many other logout post, - there is no need for logout function as the token isnt save on server side so closing and opening will result in having to login again. - jwt is using expire time for it so it will logout when the token has been expire , provided if the verify token is set to True

But what i want is to have like a remember me function where user will stay login when they close and open again, as one of the suggestion is turn the verify token to false or set expire time to weeks. But then how does the user logout if the token expire time hasnt reach yet ?

As i am using jwt and djoser, the logout function of djoser is for drf only and not for jwt. Since i am also using the api for mobile devices, so the user will stay login whenever they open the app (provided they did the first login) like facebook and many other apps.

Please give me guidance on this. Thank you

1

1 Answer 1

3

Ideally, you should be using JWT in a stateless manner, which means the there is no session(The JWT token has an expiration time and will be invalid after that time, clients need to implement some mechanism to re-authenticate or extend the token). Given that, you don't need a log out at all.

Sign up to request clarification or add additional context in comments.

3 Comments

what if user wants to logout to login to another account ? for eg: on phone/mobile devices
@JinNiiSama Then the client side application should discard the JWT (logout) and request a new JWT for the other account through login.
Yep what @ARJMP said

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.