示例#1
0
def updateUser(username):
    if not userManager.enabled:
        return jsonify(SUCCESS)

    user = userManager.findUser(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.json
        except BadRequest:
            return make_response("Malformed JSON body in request", 400)

        # change roles
        roles = ["user"]
        if "admin" in data.keys() and data["admin"]:
            roles.append("admin")
        userManager.changeUserRoles(username, roles)

        # change activation
        if "active" in data.keys():
            userManager.changeUserActivation(username, data["active"])
        return getUsers()
    else:
        abort(404)
示例#2
0
def updateUser(username):
	if not userManager.enabled:
		return jsonify(SUCCESS)

	user = userManager.findUser(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.json
		except BadRequest:
			return make_response("Malformed JSON body in request", 400)

		# change roles
		roles = ["user"]
		if "admin" in data.keys() and data["admin"]:
			roles.append("admin")
		userManager.changeUserRoles(username, roles)

		# change activation
		if "active" in data.keys():
			userManager.changeUserActivation(username, data["active"])
		return getUsers()
	else:
		abort(404)
示例#3
0
def updateUser(username):
    if userManager is None:
        return jsonify(SUCCESS)

    #add by kevin, for manage default users
    if userManager.isDefaultUsers(username):
        return make_response(("Forbidden", 403, []))
    #add end

    user = userManager.findUser(username)
    if user is not None:
        if "application/json" in request.headers["Content-Type"]:
            data = request.json

            # change roles
            roles = ["user"]
            if "admin" in data.keys() and data["admin"]:
                roles.append("admin")
            userManager.changeUserRoles(username, roles)

            # change activation
            if "active" in data.keys():
                userManager.changeUserActivation(username, data["active"])
        return getUsers()
    else:
        abort(404)
示例#4
0
def updateUser(username):
	if userManager is None:
		return jsonify(SUCCESS)

	user = userManager.findUser(username)
	if user is not None:
		if "application/json" in request.headers["Content-Type"]:
			data = request.json

			# change roles
			roles = ["user"]
			if "admin" in data.keys() and data["admin"]:
				roles.append("admin")
			userManager.changeUserRoles(username, roles)

			# change activation
			if "active" in data.keys():
				userManager.changeUserActivation(username, data["active"])
		return getUsers()
	else:
		abort(404)
示例#5
0
def updateUser(username):
    if userManager is None:
        return jsonify(SUCCESS)

    user = userManager.findUser(username)
    if user is not None:
        if "application/json" in request.headers["Content-Type"]:
            data = request.json

            # change roles
            roles = ["user"]
            if "admin" in data.keys() and data["admin"]:
                roles.append("admin")
            userManager.changeUserRoles(username, roles)

            # change activation
            if "active" in data.keys():
                userManager.changeUserActivation(username, data["active"])
        return getUsers()
    else:
        abort(404)