mirror of
https://github.com/wassname/flask-security.git
synced 2026-09-11 12:11:25 +08:00
No need to keep authentication token in DB
This commit is contained in:
@@ -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()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user