main.py 文件源码

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

项目:microAuth 作者: Gingernaut 项目源码 文件源码
def allAccounts():
    try:
        token = request.headers["Authorization"] or None

        if not token:
            return custResponse(401, "Unauthorized. Sign in required.")

        accId = accFunctions.getIdFromToken(token)

        if not accId or not accFunctions.isAdmin(accId):
            return custResponse(401, "Unauthorized. Invalid token.")

        users = [user.serialize() for user in user.query.all()]
        return custResponse(200, "Accounts successfully retrieved", {"Users": users})

    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.")


# add same as above for put del on /accounts/id
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号