Exemple #1
0
def admin_users_setlevel(sid: uuid.UUID, level: int):
    if level not in User.LEVELS:
        return json_result(-1, "invalid level")

    user: User = user_api.find_by_uuid(sid)
    user.level = level
    user_api.update_by_uuid(sid, user)
    return json_result(0, "success")
Exemple #2
0
def admin_users_update(sid: uuid.UUID):
    password = request.form["password"]
    level = request.form["level"]

    user: User = user_api.find_by_uuid(sid)
    if user == None:
        return json_result(-1, "user not found")

    user.password = password
    try:
        user.level = int(level)
    except:
        return json_result(-1, "level is not integer")
    if user.level not in User.LEVELS:
        return json_result(-1, "invalid level")

    user_api.update_by_uuid(sid, user)
    return json_result(0, "success")