main.py 文件源码

python
阅读 13 收藏 0 点赞 0 评论 0

项目:microAuth 作者: Gingernaut 项目源码 文件源码
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.")
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号