import bcrypt
from itsdangerous import TimedJSONWebSignatureSerializer as TimedSigSerializer
from app.config import SECRET_KEY, TOKEN_EXPIRES


def hash_password(password):
    return bcrypt.hashpw(password.encode('utf-8'), bcrypt.gensalt())


def verify_password(password, hashed):
    return bcrypt.hashpw(password.encode('utf-8'), hashed) == hashed


def generate_token(user_dict, expiration=TOKEN_EXPIRES):
    s = TimedSigSerializer(SECRET_KEY, expires_in=expiration)
    return s.dumps(user_dict)

@@ -86,16 +86,72 @@
 ializer%0A
+from itsdangerous import SignatureExpired, BadSignature%0A
 from app
@@ -552,8 +552,194 @@
 r_dict)%0A
+%0A%0Adef verify_token(token):%0A    s = TimedSigSerializer(SECRET_KEY)%0A    try:%0A        data = s.loads(token)%0A    except (SignatureExpired, BadSignature):%0A        return None%0A    return data%0A

Add verify token util for auth