diff --git a/apps/web/app/api/auth.ts b/apps/web/app/api/auth.ts index e6576da6..d60cb011 100644 --- a/apps/web/app/api/auth.ts +++ b/apps/web/app/api/auth.ts @@ -46,7 +46,8 @@ export function useLogout() { export function useChangePassword() { return useMutation({ mutationFn: (body: PasswordChangeRequest) => - apiData("/auth/password", { method: "POST", body }), + // 旧密码错误也是 401:留在页面显示字段错误,不当成会话失效跳登录 + apiData("/auth/password", { method: "POST", body, noAuthRedirect: true }), }); } @@ -61,7 +62,8 @@ export function useTotpStatus(enabled = true) { export function useTotpAction() { const qc = useQueryClient(); return useMutation({ - mutationFn: (body: TotpAction) => apiData("/auth/totp", { method: "POST", body }), + mutationFn: (body: TotpAction) => + apiData("/auth/totp", { method: "POST", body, noAuthRedirect: true }), onSuccess: () => { qc.invalidateQueries({ queryKey: qk.all("auth") }); },