feat(web-auth): 前端修改资料、修改密码优化
This commit is contained in:
@@ -28,12 +28,14 @@ function RequireSession({ children }: { children: ReactNode }) {
|
||||
return children;
|
||||
}
|
||||
|
||||
/** 认证页互斥:已登录访问 /login、/register 时回到主布局 */
|
||||
/** 认证页互斥:已登录访问 /login、/register 时回到来源页或主布局 */
|
||||
function RedirectIfAuthenticated({ children }: { children: ReactNode }) {
|
||||
const { status } = useSession();
|
||||
const location = useLocation();
|
||||
|
||||
if (status === 'authenticated') {
|
||||
return <Navigate to="/" replace />;
|
||||
const from = (location.state as { from?: string } | null)?.from;
|
||||
return <Navigate to={from && from.startsWith('/') ? from : '/'} replace />;
|
||||
}
|
||||
return children;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user