def update_user(username): user = userManager.find_user(username) if user is not None: if "application/json" not in request.headers["Content-Type"]: abort(400, description="Expected content-type JSON") data = request.get_json() if data is None: abort(400, description="Malformed JSON body in request") # change groups if "groups" in data: groups = data["groups"] userManager.change_user_groups(username, groups) # change permissions if "permissions" in data: permissions = data["permissions"] userManager.change_user_permissions(username, permissions) # change activation if "active" in data: userManager.change_user_activation( username, data["active"] in valid_boolean_trues ) return get_users() else: abort(404)
def update_user(username): if not userManager.enabled: return jsonify(SUCCESS) user = userManager.find_user(username) if user is not None: if not "application/json" in request.headers["Content-Type"]: return make_response("Expected content-type JSON", 400) try: data = request.get_json() except BadRequest: return make_response("Malformed JSON body in request", 400) # change groups if "groups" in data: groups = data["groups"] userManager.change_user_groups(username, groups) # change permissions if "permissions" in data: permissions = data["permissions"] userManager.change_user_permissions(username, permissions) if data is None: return make_response("Malformed JSON body in request", 400) # change activation if "active" in data: userManager.change_user_activation( username, data["active"] in valid_boolean_trues) return get_users() else: abort(404)
def get_user(username): if (current_user is not None and not current_user.is_anonymous and (current_user.get_name() == username or current_user.has_permission(Permissions.ADMIN))): user = userManager.find_user(username) if user is not None: return jsonify(user) else: abort(404) else: abort(403)