def VerifyResetToken(token): temp = serial(app.config['SECRET_KEY']) try: userID = temp.loads(token)['userID'] except: return None return User.query.get(userID)
def verify_reset_token(token): s = serial(app.config['SECRET_KEY']) try: return s.loads(toekn)['user_id'] except: return None return User.query.get(user_id)
def GetResetToken(self, expires_sec=3600): token = serial(app.config['SECRET_KEY'], expires_sec) return token.dumps({'userID': self.id}).decode('utf-8')
def get_reset_token(self, expires_sec=1800): s = serial(app.config['SECRET_KEY'], expires_sec) return s.dumps({'user_id': self.id}).decode('utf-8')
def generate_confirmation_link(self): self.s=serial(current_app.config["SECRET_KEY"],expires_in=24*3600) # by default expires in 24 h return "http://127.0.0.1:5000/auth/confirm/"+str(self.s.dumps({'id':self.id}))
def __init__(self): jwt_env = settings.from_env('jwt') self.serial = serial(secret_key=jwt_env['secret-key'], salt=jwt_env['salt'], expires_in=jwt_env['expires'])