pub fn filter_user(user: &User) -> FilteredUserExpand description
Converts a User with sensitive data into a FilteredUser safe for API responses.
This function removes password hashes and other sensitive information before
returning User data to clients. Always use this helper instead of directly
serializing User objects.
Used by all authentication endpoints to ensure passwords are never exposed.
§Arguments
user: Reference to the internalUserstruct containing password hash
§Returns
FilteredUser with only safe-to-share information:
id: User IDfirst_name,last_name: User nameusername: Login usernameis_admin: Admin privilege flag
§Important
The password hash is explicitly NOT included in the output. This prevents accidental exposure of sensitive authentication data.
§Example
ⓘ
let user = get_user_from_db(1).await?;
let safe_user = filter_user(&user); // Convert User to FilteredUser
// safe_user can be safely serialized and sent to client