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
评论列表
文章目录