refactor(auth): refresh refresh handler
zhenyi committed
Modified lib/auth/handler/refresh.rs lib/auth/handler/refresh.rs +8 −8 View lib/auth/handler/refresh.rs
@@ -1,24 +1,24 @@
1use axum::Json;
21use axum::extract::State;
32
43use crate::error::AuthError;
54use crate::features::AuthService;
6use crate::features::refresh::types::{RefreshCmd, RefreshResp};
5use export::auth::refresh::{RefreshCmd, RefreshResp};
6use export::data::{AppRequest, AppRequestData, AppResponseData};
77
88#[utoipa::path(
99 post,
1010 path = "/auth/refresh",
1111 tag = "auth",
12 request_body = RefreshCmd,
12 request_body = AppRequestData<RefreshCmd>,
1313 responses(
14 (status = 200, description = "Rotated token pair.", body = RefreshResp),
14 (status = 200, description = "Rotated token pair.", body = AppResponseData<RefreshResp>),
1515 (status = 401, description = "Invalid or expired refresh token.", body = super::openapi::ErrorBody),
1616 ),
1717)]
1818pub(crate) async fn handler(
1919 State(svc): State<AuthService>,
20 Json(cmd): Json<RefreshCmd>,
21) -> Result<Json<RefreshResp>, AuthError> {
22 let resp = svc.refresh(cmd).await?;
23 Ok(Json(resp))
20 cmd: AppRequest<RefreshCmd>,
21) -> Result<AppResponseData<RefreshResp>, AuthError> {
22 let resp = svc.refresh(cmd.into_inner()).await?;
23 Ok(AppResponseData::ok(resp))
2424}