feat: add password entry auth flow

This commit is contained in:
2026-04-21 14:50:42 +08:00
parent 5675c40119
commit c23088539e
18 changed files with 1146 additions and 25 deletions

View File

@@ -11,14 +11,14 @@ use crate::{api_response::json_error_body, request_context::RequestContext};
pub struct AppError {
status_code: StatusCode,
code: &'static str,
message: &'static str,
message: String,
details: Option<Value>,
}
#[derive(Clone, Debug, Serialize)]
pub struct ApiErrorPayload {
pub code: &'static str,
pub message: &'static str,
pub message: String,
#[serde(skip_serializing_if = "Option::is_none")]
pub details: Option<Value>,
}
@@ -30,7 +30,7 @@ impl AppError {
Self {
status_code,
code,
message,
message: message.to_string(),
details: None,
}
}
@@ -39,6 +39,11 @@ impl AppError {
self.code
}
pub fn with_message(mut self, message: impl Into<String>) -> Self {
self.message = message.into();
self
}
pub fn with_details(mut self, details: Value) -> Self {
self.details = Some(details);
self
@@ -54,7 +59,7 @@ impl AppError {
fn to_payload(&self) -> ApiErrorPayload {
ApiErrorPayload {
code: self.code,
message: self.message,
message: self.message.clone(),
details: self.details.clone(),
}
}