Closed thomascenni closed 4 years ago
Right now the only way to invalidate a token is to change the user's password. There's several ways to achieve this, which may or may not be practical:
Depending on how you're using django-sesame, you may also be able to do something with the recently introduced feature - scoped tokens. The workflow would look like:
Hope this helps!
Merci Aymeric! I have already set unusable passwords, I will do in this way. May be later I will evaluate your proposed workflow. Thanks!
Good, then it's as simple as:
assert user.has_usable_password() # let's not destroy a password accidentally
user.set_unusable_password() # change password to invalidate token
user.save()
@aaugustin How would one invalidate a token programmatically without having the user give the password? Assuming the user has a usable password.
django-sesame doesn't provide a way to do this — because it doesn't store any state beyond what django.contrib.auth already stores, and there's no piece of state that you can alter to get this effect.
Hi, is it possible to invalidate the token before its expiration ? My use case is that a user fill a form (wizard) and at the end of the wizard, if the data are valid, they are stored in the db and the token must be invalidated. Thanks.