def login():
try:
res = json.loads(request.data) or None
if not res:
return custResponse(400, "data required for update")
postEmail = res.get("emailAddress")
postPass = res.get("password")
if not utils.isValidEmail(postEmail):
return custResponse(400, "Invalid email address.")
if not utils.isValidPass(postPass):
return custResponse(400, "Invalid password. Must be at least " + configFile["Security"]["minPassLength"] + " characters long.")
accId = accFunctions.signin(postEmail, postPass)
if not accId:
return custResponse(400, "Login failed. Incorrect email or password")
accData = accFunctions.getAccData(accId)
accData["authToken"] = accFunctions.genToken(accId)
return custResponse(200, "Login Successful", accData)
except Exception as e:
if app.config["DEBUG"] == True:
print("*-*-*-*")
print(e)
return custResponse(500,{"Err": str(e)})
else:
return custResponse(500, "An unknown error occured.")
评论列表
文章目录