summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--server/src/routes/user.rs13
1 files changed, 7 insertions, 6 deletions
diff --git a/server/src/routes/user.rs b/server/src/routes/user.rs
index d5a09e2..1bb56b9 100644
--- a/server/src/routes/user.rs
+++ b/server/src/routes/user.rs
@@ -8,15 +8,16 @@ use axum::{extract::Path, routing::get, Json, Router};
/// Create routes for `/v1/users/` namespace
pub fn create_route() -> Router {
Router::new()
- .route("/", get(list_users))
+ .route("/", get(get_me))
.route("/:id", get(get_user))
}
-/// List users. Checks Authorization token
-async fn list_users(_: Claims) -> Result<Json<Vec<UserList>>, AppError> {
- let users = User::list().await?;
-
- Ok(Json(users))
+/// Get info about me
+async fn get_me(claims: Claims) -> Result<Json<UserList>, AppError> {
+ match User::find_by_id(claims.user_id).await {
+ Ok(user) => Ok(Json(user)),
+ Err(_) => Err(AppError::NotFound("User not found".to_string())),
+ }
}
/// Search an user by `user_id`. It works only if the user passed by `Authorization` token is the