25 lines
824 B
Rust
25 lines
824 B
Rust
use crate::{ApiResponse, error::ApiError};
|
|
use actix_web::{HttpResponse, Result, web};
|
|
use service::AppService;
|
|
use service::auth::me::ContextMe;
|
|
use session::Session;
|
|
|
|
#[utoipa::path(
|
|
post,
|
|
path = "/api/auth/me",
|
|
responses(
|
|
(status = 200, description = "Current user info", body = ApiResponse<ContextMe>),
|
|
(status = 401, description = "Unauthorized", body = ApiResponse<ApiError>),
|
|
(status = 500, description = "Internal server error", body = ApiResponse<ApiError>),
|
|
(status = 404, description = "Not found", body = ApiResponse<ApiError>),
|
|
),
|
|
tag = "Auth"
|
|
)]
|
|
pub async fn api_auth_me(
|
|
service: web::Data<AppService>,
|
|
session: Session,
|
|
) -> Result<HttpResponse, ApiError> {
|
|
let me = service.auth_me(session).await?;
|
|
Ok(ApiResponse::ok(me).to_response())
|
|
}
|