# File: token.py # Author: Daniel Douglas from itsdangerous import URLSafeTimedSerializer from pm_app import app # Generate and email confirmation token def generate_confirmation_token(requested,requested_by): # Generate the serializer object # serializer = URLSafeTimedSerializer(app.config['SECRET_KEY']) # Return the salty token # return serializer.dumps([requested, requested_by], salt=app.config['SECURITY_PASSWORD_SALT']) # Function to confirm a token def confirm_token(token): # Generate the serializer object # serializer = URLSafeTimedSerializer(app.config['SECRET_KEY']) try: # Unpack token # untoked = serializer.loads( token, salt=app.config['SECURITY_PASSWORD_SALT'] ) except: return False return untoked