verify sign up

This commit is contained in:
CHIEFSOFT\ameye
2024-12-08 21:06:14 -05:00
parent da81a21e0a
commit 5d3d9f57a4
+31 -9
View File
@@ -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 {