27 lines
900 B
Rust
27 lines
900 B
Rust
use crate::ApiResponse;
|
|
use crate::error::ApiError;
|
|
use actix_web::{HttpResponse, Result, web};
|
|
use service::AppService;
|
|
use service::auth::captcha::{CaptchaQuery, CaptchaResponse};
|
|
use session::Session;
|
|
|
|
#[utoipa::path(
|
|
post,
|
|
path = "/api/auth/captcha",
|
|
request_body = CaptchaQuery,
|
|
responses(
|
|
(status = 200, description = "Captcha generated", body = ApiResponse<CaptchaResponse>),
|
|
(status = 500, description = "Internal server error", body = ApiResponse<ApiError>),
|
|
(status = 404, description = "Not found", body = ApiResponse<ApiError>),
|
|
),
|
|
tag = "Auth"
|
|
)]
|
|
pub async fn api_auth_captcha(
|
|
service: web::Data<AppService>,
|
|
session: Session,
|
|
body: web::Json<CaptchaQuery>,
|
|
) -> Result<HttpResponse, ApiError> {
|
|
let resp = service.auth_captcha(&session, body.into_inner()).await?;
|
|
Ok(HttpResponse::Ok().json(ApiResponse::ok(resp)))
|
|
}
|