verify sign up
This commit is contained in:
@@ -87,17 +87,39 @@ def start_login():
|
||||
data["username"],
|
||||
data["password"]
|
||||
)
|
||||
if member:
|
||||
try:
|
||||
# token should expire after 24 hrs
|
||||
user["token"] = jwt.encode(
|
||||
{"member": member, 'exp' : datetime.datetime.utcnow() + datetime.timedelta(minutes=30)},
|
||||
app.config["SECRET_KEY"],
|
||||
algorithm="HS256"
|
||||
)
|
||||
return {
|
||||
"message": "Successfully fetched auth token",
|
||||
"data": user
|
||||
}
|
||||
except Exception as e:
|
||||
return {
|
||||
"error": "Something went wrong",
|
||||
"message": str(e)
|
||||
}, 500
|
||||
return {
|
||||
"message": "Error fetching auth token!, invalid email or password",
|
||||
"data": None,
|
||||
"error": "Unauthorized"
|
||||
}, 404
|
||||
|
||||
|
||||
GLOBAL_AVG = """SELECT * FROM members WHERE id = 1;"""
|
||||
with connection:
|
||||
with connection.cursor() as cursor:
|
||||
cursor.execute(GLOBAL_AVG)
|
||||
account = cursor.fetchone()
|
||||
#return jsonify(hello="ameye world")
|
||||
token = jwt.encode({'user': 'account', 'exp' : datetime.datetime.utcnow() + datetime.timedelta(minutes=30)},app.config['SECRET_KEY'] )
|
||||
# return {"account": account}
|
||||
return {"token": token}
|
||||
# GLOBAL_AVG = """SELECT * FROM members WHERE id = 1;"""
|
||||
# with connection:
|
||||
# with connection.cursor() as cursor:
|
||||
# cursor.execute(GLOBAL_AVG)
|
||||
# account = cursor.fetchone()
|
||||
# #return jsonify(hello="ameye world")
|
||||
# token = jwt.encode({'user': 'account', 'exp' : datetime.datetime.utcnow() + datetime.timedelta(minutes=30)},app.config['SECRET_KEY'] )
|
||||
# # return {"account": account}
|
||||
# return {"token": token}
|
||||
|
||||
except Exception as e:
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user