verify sign up
This commit is contained in:
@@ -87,17 +87,39 @@ def start_login():
|
|||||||
data["username"],
|
data["username"],
|
||||||
data["password"]
|
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;"""
|
# GLOBAL_AVG = """SELECT * FROM members WHERE id = 1;"""
|
||||||
with connection:
|
# with connection:
|
||||||
with connection.cursor() as cursor:
|
# with connection.cursor() as cursor:
|
||||||
cursor.execute(GLOBAL_AVG)
|
# cursor.execute(GLOBAL_AVG)
|
||||||
account = cursor.fetchone()
|
# account = cursor.fetchone()
|
||||||
#return jsonify(hello="ameye world")
|
# #return jsonify(hello="ameye world")
|
||||||
token = jwt.encode({'user': 'account', 'exp' : datetime.datetime.utcnow() + datetime.timedelta(minutes=30)},app.config['SECRET_KEY'] )
|
# token = jwt.encode({'user': 'account', 'exp' : datetime.datetime.utcnow() + datetime.timedelta(minutes=30)},app.config['SECRET_KEY'] )
|
||||||
# return {"account": account}
|
# # return {"account": account}
|
||||||
return {"token": token}
|
# return {"token": token}
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
return {
|
return {
|
||||||
|
|||||||
Reference in New Issue
Block a user