Added ability to get the info of the current user
This commit is contained in:
@ -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
|
||||
}
|
||||
|
Reference in New Issue
Block a user