cec6dce955
- Add git operation endpoints: archive, compare branches, diff, tree, repository extras - Add repo endpoints: contributors, delete fork, get branch/commit status/deploy key/invitation/member/release/tag/webhook, topics, release assets, webhook deliveries/retry - Add PR endpoints: review requests, templates - Add user endpoints: block/unblock, follow/unfollow, presence, personal access tokens, account restore - Add workspace endpoints: billing history, approvals, domains, integrations, invitations, members, webhooks, restore - Add internal API, notification API, IM API modules - Update route configuration and OpenAPI spec
44 lines
1.4 KiB
Rust
44 lines
1.4 KiB
Rust
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<String>),
|
|
(status = 404, description = "Invalid or expired restore link.", body = ApiErrorResponse),
|
|
)
|
|
)]
|
|
pub async fn restore_account(
|
|
service: web::Data<AppService>,
|
|
body: web::Json<RestoreAccountParams>,
|
|
) -> Result<HttpResponse, AppError> {
|
|
service.user.user_restore(&body.token).await?;
|
|
Ok(HttpResponse::Ok().json(ApiResponse::new(
|
|
"account restored successfully".to_string(),
|
|
)))
|
|
}
|