fix: handle null authOptions in LoginForm and update state initialization

This commit is contained in:
mlogclub
2026-06-13 10:19:28 +08:00
parent 0b78104978
commit 6b3cda9874
+6 -5
View File
@@ -40,17 +40,14 @@ export function LoginForm({
const { session } = useAuth()
const [isPending, setIsPending] = useState(false)
const [isWxWorkEnv, setIsWxWorkEnv] = useState(false)
const [authOptions, setAuthOptions] = useState<AuthOptions>({
wxworkEnabled: false,
oidcEnabled: false,
})
const [authOptions, setAuthOptions] = useState<AuthOptions | null>(null)
const nextPath = searchParams.get("next")
const wxworkError = searchParams.get("wxworkError")
const oidcError = searchParams.get("oidcError")
const redirectPath =
nextPath && nextPath.startsWith("/") ? nextPath : "/dashboard"
const enabledProviderCount =
Number(authOptions.wxworkEnabled) + Number(authOptions.oidcEnabled)
Number(authOptions?.wxworkEnabled) + Number(authOptions?.oidcEnabled)
useEffect(() => {
if (session) {
@@ -115,6 +112,10 @@ export function LoginForm({
}
}
if (!authOptions) {
return null
}
return (
<div
className={cn("flex flex-col gap-6", className)}