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

93 lines
2.9 KiB
Rust
Raw Normal View History

2025-03-19 23:17:50 +07:00
use super::{
AuthLoginRequestDto, AuthRegisterRequestDto, AuthResendOtpRequestDto, AuthService,
AuthVerifyEmailRequestDto,
};
2025-03-14 17:50:37 +07:00
use crate::{v1::AuthLoginResponsetDto, AppState};
use crate::{MessageResponseDto, ResponseSuccessDto};
2025-03-19 23:17:50 +07:00
use axum::{response::IntoResponse, Extension, Json};
2025-03-14 17:50:37 +07:00
#[utoipa::path(
post,
path = "/v1/auth/login",
request_body = AuthLoginRequestDto,
responses(
(status = 200, description = "Login successful", body = ResponseSuccessDto<AuthLoginResponsetDto>),
2025-03-19 23:17:50 +07:00
(status = 401, description = "Login failed", body = MessageResponseDto)
2025-03-14 17:50:37 +07:00
),
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(
2025-03-19 23:17:50 +07:00
(status = 200, description = "Register successful", body = MessageResponseDto),
(status = 401, description = "Register failed", body = MessageResponseDto)
2025-03-14 17:50:37 +07:00
),
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
}
2025-03-19 23:17:50 +07:00
#[utoipa::path(
post,
path = "/v1/auth/verify",
request_body = AuthVerifyEmailRequestDto,
responses(
(status = 200, description = "Verify email successful", body = MessageResponseDto),
(status = 401, description = "Verify email failed", body = MessageResponseDto)
),
tag = "Authentication"
)]
pub async fn post_verify_email(
Extension(state): Extension<AppState>,
Json(payload): Json<AuthVerifyEmailRequestDto>,
) -> impl IntoResponse {
AuthService::mutation_verify_email(payload, &state).await
}
#[utoipa::path(
post,
path = "/v1/auth/resend",
request_body = AuthResendOtpRequestDto,
responses(
(status = 200, description = "Resend otp successful", body = MessageResponseDto),
(status = 401, description = "Resend otp failed", body = MessageResponseDto)
),
tag = "Authentication"
)]
pub async fn post_resend_otp(
Extension(state): Extension<AppState>,
Json(payload): Json<AuthResendOtpRequestDto>,
) -> impl IntoResponse {
AuthService::mutation_resend_otp(payload, &state).await
}
#[utoipa::path(
post,
path = "/v1/auth/forgot",
request_body = AuthResendOtpRequestDto,
responses(
(status = 200, description = "Forgot password request successful", body = MessageResponseDto),
(status = 401, description = "Forgot password request failed", body = MessageResponseDto)
),
tag = "Authentication"
)]
pub async fn post_forgot_password(
Extension(state): Extension<AppState>,
Json(payload): Json<AuthResendOtpRequestDto>,
) -> impl IntoResponse {
AuthService::mutation_forgot_password(payload, &state).await
}