refactor(auth): refresh password forgot handler
zhenyi committed
Modified lib/auth/handler/password/forgot.rs lib/auth/handler/password/forgot.rs +7 −7 View lib/auth/handler/password/forgot.rs
@@ -1,10 +1,10 @@
1use axum::Json;
21use axum::extract::{Extension, State};
32use axum_extra::extract::cookie::CookieJar;
43
54use crate::error::AuthError;
65use crate::features::AuthService;
76use crate::features::forgot_password::types::{ForgotPasswordCmd, ForgotPasswordResp};
7use export::data::{AppRequest, AppRequestData, AppResponseData};
88
99use super::super::cookies;
1010
@@ -12,9 +12,9 @@
1212 post,
1313 path = "/auth/password/forgot",
1414 tag = "auth",
15 request_body = ForgotPasswordCmd,
15 request_body = AppRequestData<ForgotPasswordCmd>,
1616 responses(
17 (status = 200, description = "Request accepted. The response shape is constant whether or not the email is known; the temp_key cookie carries the token for the subsequent reset.", body = ForgotPasswordResp),
17 (status = 200, description = "Request accepted. The response shape is constant whether or not the email is known; the temp_key cookie carries the token for the subsequent reset.", body = AppResponseData<ForgotPasswordResp>),
1818 (status = 400, description = "Validation / PoW failure.", body = super::super::openapi::ErrorBody),
1919 (status = 429, description = "Rate limited.", body = super::super::openapi::ErrorBody),
2020 ),
@@ -23,10 +23,10 @@
2323 State(svc): State<AuthService>,
2424 jar: CookieJar,
2525 cid: Option<Extension<rate_limit::ClientId>>,
26 Json(cmd): Json<ForgotPasswordCmd>,
27) -> Result<(CookieJar, Json<ForgotPasswordResp>), AuthError> {
28 let resp = svc.forgot_password(cmd, cid.map(|c| c.0 .0)).await?;
26 cmd: AppRequest<ForgotPasswordCmd>,
27) -> Result<(CookieJar, AppResponseData<ForgotPasswordResp>), AuthError> {
28 let resp = svc.forgot_password(cmd.into_inner(), cid.map(|c| c.0 .0)).await?;
2929 let cookie = cookies::temp_key_to_cookie(&svc.config, &resp.temp_key);
3030 let jar = jar.add(cookie);
31 Ok((jar, Json(resp)))
31 Ok((jar, AppResponseData::ok(resp)))
3232}