feat(auth): update login routes and add WxWork login callback handling

This commit is contained in:
mlogclub
2026-04-24 11:35:29 +08:00
parent 5fa30d29ef
commit 7889ecb0d2
8 changed files with 22 additions and 15 deletions
+5 -4
View File
@@ -33,7 +33,8 @@ export function AuthProvider({ children }: { children: ReactNode }) {
const router = useRouter()
const [session, setSession] = useState<AuthSession | null>(null)
const [ready, setReady] = useState(false)
const requiresAuth = pathname?.startsWith("/dashboard") ?? false
const isDashboardLoginRoute = pathname?.startsWith("/dashboard/login") ?? false
const requiresAuth = (pathname?.startsWith("/dashboard") ?? false) && !isDashboardLoginRoute
const refreshProfile = useCallback(async () => {
const stored = readSession()
@@ -58,7 +59,7 @@ export function AuthProvider({ children }: { children: ReactNode }) {
setSession(null)
if (requiresAuth) {
startTransition(() => {
router.replace("/login")
router.replace("/dashboard/login")
})
}
} finally {
@@ -71,7 +72,7 @@ export function AuthProvider({ children }: { children: ReactNode }) {
await logout(current?.refreshToken)
setSession(null)
startTransition(() => {
router.replace("/login")
router.replace("/dashboard/login")
})
}
@@ -86,7 +87,7 @@ export function AuthProvider({ children }: { children: ReactNode }) {
setReady(true)
if (requiresAuth) {
startTransition(() => {
router.replace("/login")
router.replace("/dashboard/login")
})
}
}, [requiresAuth, refreshProfile, router])