Added ability to get the info of the current user

This commit is contained in:
2024-08-03 16:44:34 +03:00
parent cd3ab9b6bc
commit 40f0526500
3 changed files with 42 additions and 10 deletions

View File

@ -5,12 +5,21 @@ pub struct Params {
user_id: i32,
}
pub async fn get(
State(pool): State<Pool>,
Query(params): Query<Params>,
) -> Result<Json<db::users::UserInfo>, StatusCode> {
type Response = Result<Json<db::users::UserInfo>, StatusCode>;
pub async fn get(State(pool): State<Pool>, Query(params): Query<Params>) -> Response {
let info = db::users::get(params.user_id, &pool)
.await
.handle_internal()?;
Ok(Json(info))
}
pub async fn current(state: State<Pool>, claims: Claims) -> Response {
get(
state,
Query(Params {
user_id: claims.user_id,
}),
)
.await
}