feat(client): 首次登录改密守卫与错误文案(F35,F38)
- 登录响应支持 mustChangePassword 并强制跳转改密页 - 新增改密页面与全局路由守卫 - 完善 AUTH_002/SYS_429/VALID_00x 等错误提示
这个提交包含在:
@@ -18,7 +18,7 @@ function toLoginRedirect(pathname: string, search: string, hash: string) {
|
||||
|
||||
export function RequireAuth({ children }: PropsWithChildren) {
|
||||
const location = useLocation();
|
||||
const { accessToken, me, ready } = useAuth();
|
||||
const { accessToken, me, ready, mustChangePassword } = useAuth();
|
||||
|
||||
if (!ready) {
|
||||
return <FullPageLoading />;
|
||||
@@ -33,17 +33,24 @@ export function RequireAuth({ children }: PropsWithChildren) {
|
||||
);
|
||||
}
|
||||
|
||||
if (mustChangePassword && location.pathname !== "/change-password") {
|
||||
return <Navigate to="/change-password" replace />;
|
||||
}
|
||||
|
||||
return <>{children}</>;
|
||||
}
|
||||
|
||||
export function GuestOnly({ children }: PropsWithChildren) {
|
||||
const { accessToken, me, ready } = useAuth();
|
||||
const { accessToken, me, ready, mustChangePassword } = useAuth();
|
||||
|
||||
if (!ready) {
|
||||
return <FullPageLoading />;
|
||||
}
|
||||
|
||||
if (accessToken && me) {
|
||||
if (mustChangePassword) {
|
||||
return <Navigate to="/change-password" replace />;
|
||||
}
|
||||
return <Navigate to="/dashboard" replace />;
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ import { Navigate, Route, Routes } from "react-router-dom";
|
||||
import { AppShellLayout } from "../layouts/AppShellLayout";
|
||||
import { AuthLayout } from "../layouts/AuthLayout";
|
||||
import { AuditLogsPage } from "../pages/AuditLogsPage";
|
||||
import { ChangePasswordPage } from "../pages/ChangePasswordPage";
|
||||
import { DashboardPage } from "../pages/DashboardPage";
|
||||
import { DelegationsPage } from "../pages/DelegationsPage";
|
||||
import { ForbiddenPage } from "../pages/ForbiddenPage";
|
||||
@@ -31,6 +32,17 @@ export function AppRouter() {
|
||||
<Route index element={<LoginPage />} />
|
||||
</Route>
|
||||
|
||||
<Route
|
||||
path="/change-password"
|
||||
element={
|
||||
<RequireAuth>
|
||||
<AuthLayout />
|
||||
</RequireAuth>
|
||||
}
|
||||
>
|
||||
<Route index element={<ChangePasswordPage />} />
|
||||
</Route>
|
||||
|
||||
<Route
|
||||
path="/"
|
||||
element={
|
||||
|
||||
在新工单中引用
屏蔽一个用户