summaryrefslogtreecommitdiff
path: root/server/src
diff options
context:
space:
mode:
Diffstat (limited to 'server/src')
-rw-r--r--server/src/routes/user.rs8
1 files changed, 4 insertions, 4 deletions
diff --git a/server/src/routes/user.rs b/server/src/routes/user.rs
index d44df66..a3d7a5e 100644
--- a/server/src/routes/user.rs
+++ b/server/src/routes/user.rs
@@ -9,7 +9,7 @@ use axum::{extract::Path, routing::get, Json, Router};
pub fn create_route() -> Router {
Router::new()
.route("/", get(list_users).post(create_user))
- .route("/:id", get(get_user))
+ .route("/me", get(get_user))
}
/// List users. Checks Authorization token
@@ -30,9 +30,9 @@ async fn create_user(
Ok(Json(user_new))
}
-/// Get an user with id = `user_id`. Checks Authorization token
-async fn get_user(Path(user_id): Path<i32>, _: Claims) -> Result<Json<UserList>, AppError> {
- match User::find_by_id(user_id).await {
+/// Get the user from the `Authorization` header token
+async fn get_user(claims: Claims) -> Result<Json<UserList>, AppError> {
+ match User::find_by_id(claims.user_id).await {
Ok(user) => Ok(Json(user)),
Err(_) => Err(AppError::NotFound),
}