feat(auth): add comprehensive authentication system with 2FA support
- Add new auth module with captcha, login, logout, register, and email verification endpoints - Implement two-factor authentication with TOTP enable, disable, verify, and backup codes regeneration - Create RSA public key endpoint for secure password encryption - Add user profile management with get current user and email retrieval - Integrate OpenAPI documentation for all authentication endpoints - Implement password reset functionality with email verification flow - Add comprehensive API response structures with proper error handling - Configure all auth routes under /api/v1/auth scope with proper tagging
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
use actix_web::{HttpResponse, web};
|
||||
|
||||
use crate::api::response::{ApiErrorResponse, ApiResponse};
|
||||
use crate::error::AppError;
|
||||
use crate::service::AppService;
|
||||
use crate::service::auth::me::ContextMe;
|
||||
use crate::session::Session;
|
||||
|
||||
#[utoipa::path(
|
||||
get,
|
||||
path = "/api/v1/auth/me",
|
||||
tag = "Auth",
|
||||
operation_id = "authGetCurrentUser",
|
||||
summary = "Get current signed-in user context",
|
||||
description = "Return the current user's basic profile, preferred language, timezone, and notification summary using the user_uid bound to the session. This endpoint is typically used to restore the login state when the frontend app starts.",
|
||||
responses(
|
||||
(status = 200, description = "The current session is authenticated. Returns the user context.", body = ApiResponse<ContextMe>),
|
||||
(status = 401, description = "The current session is unauthenticated or the login state has expired.", body = ApiErrorResponse),
|
||||
(status = 404, description = "The user in the session no longer exists, has been disabled, or has been deleted.", body = ApiErrorResponse),
|
||||
(status = 500, description = "Database read failed.", body = ApiErrorResponse)
|
||||
)
|
||||
)]
|
||||
pub async fn handle(
|
||||
service: web::Data<AppService>,
|
||||
session: Session,
|
||||
) -> Result<HttpResponse, AppError> {
|
||||
let data = service.auth.auth_me(session).await?;
|
||||
Ok(HttpResponse::Ok().json(ApiResponse::new(data)))
|
||||
}
|
||||
Reference in New Issue
Block a user