-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcurrent_user.rs
More file actions
executable file
·36 lines (33 loc) · 1.37 KB
/
Copy pathcurrent_user.rs
File metadata and controls
executable file
·36 lines (33 loc) · 1.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
use axum::{
extract::{Extension, State},
Json,
};
use payego_core::services::auth_service::user::{
ApiError, AppState, Claims, CurrentUserResponse, UserService,
};
use payego_primitives::error::ApiErrorResponse;
use std::sync::Arc;
#[utoipa::path(
get,
path = "/api/user/current",
tag = "User",
summary = "Get current authenticated user details",
description = "Retrieves profile information for the currently authenticated user based on the JWT bearer token. \
Returns user data including ID, email, name, phone, and account status. \
Requires a valid authentication token.",
operation_id = "getCurrentUser",
responses(
(status = 200,description = "Successfully retrieved current user data",body = CurrentUserResponse,),
(status = 401,description = "Unauthorized – missing, invalid, or expired token",body = ApiErrorResponse,),
(status = 500,description = "Internal server error – unexpected issue on server side",body = ApiErrorResponse),
),
security(("bearerAuth" = [])),
)]
pub async fn current_user_details(
State(state): State<Arc<AppState>>,
Extension(claims): Extension<Claims>,
) -> Result<Json<CurrentUserResponse>, ApiError> {
let user_id = claims.user_id()?;
let response = UserService::current_user_summary(&state, user_id).await?;
Ok(Json(response))
}