gitdataai/libs/api/auth/logout.rs
2026-04-15 09:08:09 +08:00

25 lines
787 B
Rust

use crate::ApiResponse;
use crate::error::ApiError;
use actix_web::{HttpResponse, Result, web};
use service::AppService;
use session::Session;
#[utoipa::path(
post,
path = "/api/auth/logout",
responses(
(status = 401, description = "Unauthorized", body = ApiResponse<ApiError>),
(status = 200, description = "Logout successful", body = ApiResponse<String>),
(status = 500, description = "Internal server error", body = ApiResponse<ApiError>),
(status = 404, description = "Not found", body = ApiResponse<ApiError>),
),
tag = "Auth"
)]
pub async fn api_auth_logout(
service: web::Data<AppService>,
session: Session,
) -> Result<HttpResponse, ApiError> {
service.auth_logout(&session).await?;
Ok(crate::api_success())
}