No need to keep authentication token in DB

This commit is contained in:
Matt Wright
2012-08-14 16:21:31 -04:00
parent 6f7d5378e7
commit 68b0410d1b
5 changed files with 9 additions and 25 deletions
-12
View File
@@ -41,9 +41,6 @@ def login_user(user, remember=True):
if not _login_user(user, remember):
return False
if user.authentication_token is None:
user.authentication_token = generate_authentication_token(user)
if _security.trackable:
old_current, new_current = user.current_login_at, datetime.utcnow()
user.last_login_at = old_current or new_current
@@ -90,15 +87,6 @@ def encrypt_password(password, salt=None, use_hmac=False):
return _pwd_context.encrypt(hmac_value)
def generate_authentication_token(user):
"""Generates a unique authentication token for the specified user.
:param user: The user to work with
"""
data = [str(user.id), md5(user.email)]
return _security.token_auth_serializer.dumps(data)
def md5(data):
return hashlib.md5(data).hexdigest()