refactor(auth): refresh pow handler
zhenyi committed
Modified lib/auth/handler/pow.rs lib/auth/handler/pow.rs +4 −4 View lib/auth/handler/pow.rs
@@ -1,9 +1,9 @@
11use axum::extract::{Extension, State};
2use axum::Json;
32
43use crate::error::AuthError;
54use crate::features::AuthService;
65use crate::pow::Challenge;
6use export::data::AppResponseData;
77
88/// A freshly issued, client-bound PoW challenge for the caller to solve.
99#[derive(Debug, Clone, serde::Serialize, utoipa::ToSchema)]
@@ -20,7 +20,7 @@
2020 path = "/auth/pow/challenge",
2121 tag = "auth",
2222 responses(
23 (status = 200, description = "A fresh PoW challenge bound to this client.", body = PowChallengeResp),
23 (status = 200, description = "A fresh PoW challenge bound to this client.", body = AppResponseData<PowChallengeResp>),
2424 (status = 400, description = "PoW not configured.", body = super::openapi::ErrorBody),
2525 (status = 429, description = "Rate limited.", body = super::openapi::ErrorBody),
2626 ),
@@ -28,9 +28,9 @@
2828pub(crate) async fn handler(
2929 State(svc): State<AuthService>,
3030 Extension(cid): Extension<rate_limit::ClientId>,
31) -> Result<Json<PowChallengeResp>, AuthError> {
31) -> Result<AppResponseData<PowChallengeResp>, AuthError> {
3232 let (challenge, ttl) = svc.pow.issue_challenge_bound(&cid.0).await?;
33 Ok(Json(PowChallengeResp {
33 Ok(AppResponseData::ok(PowChallengeResp {
3434 challenge,
3535 ttl_seconds: ttl,
3636 }))