I would like to use django-rest-framework token to authenticate users. My workflow would be:
User requests a page
- If auth token is present, respond with the requested data.
- If auth token is not present, redirect to the login page (with the request page).
Inside the login page, user submit their credentials
- If credentials were correctly authenticated, get or create a token for that user and redirect back to the requested page with the token.
- Else, respond with error.
Lastly,
- When the user logs out, delete the token for that user.
So my question is, is it okay to delete and create a new token for every login if the user has already logged out? Also I assume the token will be unique, am I correct? Your help and guidance is very much appreciated. Thank you.