Files
imphnen-backend-service/src/apps/v1/auth/auth_controller.rs
T

40 lines
1.2 KiB
Rust
Raw Normal View History

2025-03-14 09:53:20 +07:00
use super::{AuthLoginRequestDto, AuthRegisterRequestDto, AuthService};
2025-03-14 17:50:37 +07:00
use crate::{v1::AuthLoginResponsetDto, AppState};
2025-03-13 23:40:16 +07:00
use axum::{response::IntoResponse, Extension, Json};
2025-02-25 02:00:19 +07:00
2025-03-14 17:50:37 +07:00
use crate::{MessageResponseDto, ResponseSuccessDto};
#[utoipa::path(
post,
path = "/v1/auth/login",
request_body = AuthLoginRequestDto,
responses(
(status = 200, description = "Login successful", body = ResponseSuccessDto<AuthLoginResponsetDto>),
(status = 401, description = "Unauthorized", body = MessageResponseDto)
),
tag = "Authentication"
)]
2025-02-25 02:00:19 +07:00
pub async fn post_login(
Extension(state): Extension<AppState>,
Json(payload): Json<AuthLoginRequestDto>,
) -> impl IntoResponse {
2025-03-14 09:53:20 +07:00
AuthService::mutation_login(payload, &state).await
2025-02-08 00:58:54 +07:00
}
2025-03-13 23:40:16 +07:00
2025-03-14 17:50:37 +07:00
#[utoipa::path(
post,
path = "/v1/auth/register",
request_body = AuthRegisterRequestDto,
responses(
(status = 200, description = "Login successful", body = MessageResponseDto),
(status = 401, description = "Unauthorized", body = MessageResponseDto)
),
tag = "Authentication"
)]
2025-03-13 23:40:16 +07:00
pub async fn post_register(
Extension(state): Extension<AppState>,
Json(payload): Json<AuthRegisterRequestDto>,
) -> impl IntoResponse {
2025-03-14 09:53:20 +07:00
AuthService::mutation_register(payload, &state).await
2025-03-13 23:40:16 +07:00
}