|
|
|
@ -217,7 +217,6 @@ pub async fn verify_admin_code(code: &str) -> Result<(), ApiError> {
|
|
|
|
new_code: Some(code),
|
|
|
|
new_code: Some(code),
|
|
|
|
};
|
|
|
|
};
|
|
|
|
let resp = gloo::net::http::Request::post("/api/admin/reset-auth-code")
|
|
|
|
let resp = gloo::net::http::Request::post("/api/admin/reset-auth-code")
|
|
|
|
.header("X-Auth-Code", "")
|
|
|
|
|
|
|
|
.header("X-Admin-Code", code)
|
|
|
|
.header("X-Admin-Code", code)
|
|
|
|
.json(&body)
|
|
|
|
.json(&body)
|
|
|
|
.map_err(|e| ApiError::Network(e.to_string()))?
|
|
|
|
.map_err(|e| ApiError::Network(e.to_string()))?
|
|
|
|
@ -237,25 +236,22 @@ pub async fn verify_admin_code(code: &str) -> Result<(), ApiError> {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// Call `POST /api/admin/reset-auth-code` to rotate a quote's auth code.
|
|
|
|
/// Call `POST /api/admin/reset-auth-code` to rotate the admin auth code.
|
|
|
|
///
|
|
|
|
///
|
|
|
|
/// # Arguments
|
|
|
|
/// # Arguments
|
|
|
|
/// - `current` — the current auth code for the quote (sent as `X-Auth-Code` header).
|
|
|
|
|
|
|
|
/// - `new_code` — an optional new passphrase; if `None` one is generated server-side.
|
|
|
|
/// - `new_code` — an optional new passphrase; if `None` one is generated server-side.
|
|
|
|
/// - `admin_code` — the admin super-auth code (sent as `X-Admin-Code` header).
|
|
|
|
/// - `admin_code` — the admin auth code (sent as `X-Admin-Code` header).
|
|
|
|
///
|
|
|
|
///
|
|
|
|
/// Returns the new auth code string on HTTP 200, or:
|
|
|
|
/// Returns the new auth code string on HTTP 200, or:
|
|
|
|
/// - [`ApiError::Forbidden`] on HTTP 403 (wrong admin code),
|
|
|
|
/// - [`ApiError::Forbidden`] on HTTP 403 (wrong admin code),
|
|
|
|
/// - [`ApiError::Server`] for other non-200 responses,
|
|
|
|
/// - [`ApiError::Server`] for other non-200 responses,
|
|
|
|
/// - [`ApiError::Network`] / [`ApiError::Parse`] for connection/parse errors.
|
|
|
|
/// - [`ApiError::Network`] / [`ApiError::Parse`] for connection/parse errors.
|
|
|
|
pub async fn admin_reset_auth_code(
|
|
|
|
pub async fn admin_reset_auth_code(
|
|
|
|
current: &str,
|
|
|
|
|
|
|
|
new_code: Option<&str>,
|
|
|
|
new_code: Option<&str>,
|
|
|
|
admin_code: &str,
|
|
|
|
admin_code: &str,
|
|
|
|
) -> Result<String, ApiError> {
|
|
|
|
) -> Result<String, ApiError> {
|
|
|
|
let body = ResetAuthCodeBody { new_code };
|
|
|
|
let body = ResetAuthCodeBody { new_code };
|
|
|
|
let resp = gloo::net::http::Request::post("/api/admin/reset-auth-code")
|
|
|
|
let resp = gloo::net::http::Request::post("/api/admin/reset-auth-code")
|
|
|
|
.header("X-Auth-Code", current)
|
|
|
|
|
|
|
|
.header("X-Admin-Code", admin_code)
|
|
|
|
.header("X-Admin-Code", admin_code)
|
|
|
|
.json(&body)
|
|
|
|
.json(&body)
|
|
|
|
.map_err(|e| ApiError::Network(e.to_string()))?
|
|
|
|
.map_err(|e| ApiError::Network(e.to_string()))?
|
|
|
|
|