pub async fn update_user(
__arg0: Path<i16>,
__arg1: State<Arc<AppState>>,
__arg2: Json<UserUpdateScheme>,
) -> Result<impl IntoResponse, (StatusCode, Json<Value>)>Expand description
Updates an existing user’s information.
This endpoint allows administrators to modify a User’s first_name, last_name,
username, is_admin status, and optionally their password. If new_pwd in the
request body is an empty string, the user’s password remains unchanged.
§Arguments
Path(id): The ID of theUserto update, extracted from the URL path.State(data): Application state containingAppStatefor database access.Json(body):UserUpdateSchemecontaining the fields to update.
§Returns
200 OKwith theFilteredUserobject of the updated user (converted viafilter_user).404 Not Foundif a user with the given ID does not exist.500 Internal Server Errorif a database query or password hashing error occurs.
§Security Note
- Passwords are hashed using Argon2 before storage.
- This endpoint requires admin privileges (enforced by middleware via
validate_admin).