Invalidate all session tokens when a user signs out
Fixes https://jira.coreos.com/browse/QS-85
This commit is contained in:
parent
d405f6f158
commit
1d1c6f0606
4 changed files with 16 additions and 4 deletions
|
@ -104,8 +104,7 @@ def change_password(user, new_password):
|
|||
pw_hash = hash_password(new_password)
|
||||
user.invalid_login_attempts = 0
|
||||
user.password_hash = pw_hash
|
||||
user.uuid = str(uuid4())
|
||||
user.save()
|
||||
invalidate_all_sessions(user)
|
||||
|
||||
# Remove any password required notifications for the user.
|
||||
notification.delete_notifications_by_kind(user, 'password_required')
|
||||
|
@ -593,6 +592,13 @@ def get_user_or_org_by_customer_id(customer_id):
|
|||
except User.DoesNotExist:
|
||||
return None
|
||||
|
||||
def invalidate_all_sessions(user):
|
||||
""" Invalidates all existing user sessions by rotating the user's UUID. """
|
||||
if not user:
|
||||
return
|
||||
|
||||
user.uuid = str(uuid4())
|
||||
user.save()
|
||||
|
||||
def get_matching_user_namespaces(namespace_prefix, username, limit=10):
|
||||
namespace_search = prefix_search(Namespace.username, namespace_prefix)
|
||||
|
|
Reference in a new issue