You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a question to ask. I cannot figure out how to force previously logged in sessions to logout while attempting to login on a new device for which a session does not exist.
This is specifically helpful when paired with TOKEN_LIMIT_PER_USER=1, Without implementing this behaviour, a user would be forced to login on their previously logged in device before logging into a new one (matters are worse when its about a mobile app)
How can I achieve this behavior? Is anything wrong with that idea?
The text was updated successfully, but these errors were encountered:
I got it to work. Requires overriding the post method of KnoxLoginView.
classLoginView(KnoxLoginView):
authentication_classes= (BasicAuthentication,)
defpost(self, request, format=None):
ifrequest.user.is_authenticated:
print(f"User already authenticated but a new token was requested: {request.user.id}")
# Delete all existing tokens for that userrequest.user.auth_token_set.all().delete()
returnsuper().post(request, format=format)
Perhaps exposing a pre_login signal could be a better solution?
I have a question to ask. I cannot figure out how to force previously logged in sessions to logout while attempting to login on a new device for which a session does not exist.
This is specifically helpful when paired with
TOKEN_LIMIT_PER_USER=1
, Without implementing this behaviour, a user would be forced to login on their previously logged in device before logging into a new one (matters are worse when its about a mobile app)How can I achieve this behavior? Is anything wrong with that idea?
The text was updated successfully, but these errors were encountered: