use actix_web::{HttpResponse, web}; use serde::Deserialize; use crate::api::response::{ApiErrorResponse, ApiResponse}; use crate::error::AppError; use crate::service::AppService; #[derive(Deserialize, utoipa::ToSchema)] pub struct RestoreAccountParams { pub token: String, } /// Restore a deleted user account /// /// Restores a user account that was marked for deletion. /// The restore token is sent to the user's verified email when the account is deleted. /// Tokens are valid for 30 days. After expiry, the data is preserved but the user /// must contact support to restore. /// /// This endpoint does not require authentication (the restore token serves as proof of identity). #[utoipa::path( post, path = "/api/v1/user/account/restore", tag = "User", operation_id = "userRestoreAccount", request_body( content = RestoreAccountParams, description = "Restore token received via email." ), responses( (status = 200, description = "Account restored successfully.", body = ApiResponse), (status = 404, description = "Invalid or expired restore link.", body = ApiErrorResponse), ) )] pub async fn restore_account( service: web::Data, body: web::Json, ) -> Result { service.user.user_restore(&body.token).await?; Ok(HttpResponse::Ok().json(ApiResponse::new( "account restored successfully".to_string(), ))) }