blob: 6c9001771eeb88429ed9ba7087a7eb04fcb7e938 [file] [log] [blame]
from flask import current_app
from itsdangerous import URLSafeTimedSerializer
def generate_token(email):
serializer = URLSafeTimedSerializer(current_app.config['SECRET_KEY'])
return serializer.dumps(email, salt=current_app.config['SECURITY_PASSWORD_SALT'])
def confirm_token(token, expiration=86400):
serializer = URLSafeTimedSerializer(current_app.config['SECRET_KEY'])
try:
email = serializer.loads(
token,
salt=current_app.config['SECURITY_PASSWORD_SALT'],
max_age=expiration
)
return email
except:
return False