MCPcopy Create free account
hub / github.com/AstroPrint/AstroBox / changePasswordForUser

Function changePasswordForUser

src/octoprint/server/api/users.py:111–125  ·  view source on GitHub ↗
(username)

Source from the content-addressed store, hash-verified

109@api.route("/users/<username>/password", methods=["PUT"])
110@restricted_access
111def changePasswordForUser(username):
112 if userManager is None:
113 return jsonify(SUCCESS)
114
115 if current_user is not None and not current_user.is_anonymous and (current_user.get_name() == username or current_user.is_admin()):
116 if "application/json" in request.headers["Content-Type"]:
117 data = request.json
118 if "password" in data.keys() and data["password"]:
119 try:
120 userManager.changeUserPassword(username, data["password"])
121 except users.UnknownUser:
122 return make_response(("Unknown user: %s" % username, 404, []))
123 return jsonify(SUCCESS)
124 else:
125 return make_response(("Forbidden", 403, []))
126
127
128@api.route("/users/<username>/apikey", methods=["DELETE"])

Callers

nothing calls this directly

Calls 3

is_adminMethod · 0.80
get_nameMethod · 0.45
changeUserPasswordMethod · 0.45

Tested by

no test coverage detected