Add function to get user by id
This commit is contained in:
parent
ddcb4a5be7
commit
89433df8b6
12
src/users.rs
12
src/users.rs
@ -128,3 +128,15 @@ pub async fn get_user(username_or_email: String) -> Result<Option<User>, ServerF
|
||||
|
||||
Ok(user)
|
||||
}
|
||||
|
||||
#[server(endpoint = "get_user_by_id")]
|
||||
pub async fn get_user_by_id(user_id: i32) -> Result<Option<User>, ServerFnError> {
|
||||
let mut user = find_user_by_id(user_id).await?;
|
||||
|
||||
// Remove the password hash before returning the user
|
||||
if let Some(user) = user.as_mut() {
|
||||
user.password = None;
|
||||
}
|
||||
|
||||
Ok(user)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user