Skip to content
Clone

refactor(auth): refresh email resend handler

zhenyi committed
parent 6eaecce commit a5bdaf7 Browse files

1 file changed

+7 −7

Modified lib/auth/handler/email/resend.rs View lib/auth/handler/email/resend.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::resend_code::types::{ResendCodeCmd, ResendCodeResp};
7use export::data::{AppRequest, AppRequestData, AppResponseData};
88
99use super::super::cookies;
1010
@@ -12,9 +12,9 @@
1212 post,
1313 path = "/auth/email/resend",
1414 tag = "auth",
15 request_body = ResendCodeCmd,
15 request_body = AppRequestData<ResendCodeCmd>,
1616 responses(
17 (status = 200, description = "New code issued (or silently no-op if the email is unknown).", body = ResendCodeResp),
17 (status = 200, description = "New code issued (or silently no-op if the email is unknown).", body = AppResponseData<ResendCodeResp>),
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,12 +23,12 @@
2323 State(svc): State<AuthService>,
2424 jar: CookieJar,
2525 cid: Option<Extension<rate_limit::ClientId>>,
26 Json(cmd): Json<ResendCodeCmd>,
27) -> Result<(CookieJar, Json<ResendCodeResp>), AuthError> {
26 cmd: AppRequest<ResendCodeCmd>,
27) -> Result<(CookieJar, AppResponseData<ResendCodeResp>), AuthError> {
2828 let resp = svc
29 .resend_verification_code(cmd, cid.map(|c| c.0 .0))
29 .resend_verification_code(cmd.into_inner(), cid.map(|c| c.0 .0))
3030 .await?;
3131 let cookie = cookies::temp_key_to_cookie(&svc.config, &resp.temp_key);
3232 let jar = jar.add(cookie);
33 Ok((jar, Json(resp)))
33 Ok((jar, AppResponseData::ok(resp)))
3434}