diff options
Diffstat (limited to 'src/web/lib/user_utils.py')
-rw-r--r-- | src/web/lib/user_utils.py | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/web/lib/user_utils.py b/src/web/lib/user_utils.py new file mode 100644 index 00000000..78468379 --- /dev/null +++ b/src/web/lib/user_utils.py @@ -0,0 +1,23 @@ + + +from itsdangerous import URLSafeTimedSerializer + +from bootstrap import application + + +def generate_confirmation_token(email): + serializer = URLSafeTimedSerializer(app.config['SECRET_KEY']) + return serializer.dumps(email, salt=app.config['SECURITY_PASSWORD_SALT']) + + +def confirm_token(token, expiration=3600): + serializer = URLSafeTimedSerializer(app.config['SECRET_KEY']) + try: + email = serializer.loads( + token, + salt=app.config['SECURITY_PASSWORD_SALT'], + max_age=expiration + ) + except: + return False + return email |