fix: handle null authOptions in LoginForm and update state initialization
This commit is contained in:
@@ -40,17 +40,14 @@ export function LoginForm({
|
|||||||
const { session } = useAuth()
|
const { session } = useAuth()
|
||||||
const [isPending, setIsPending] = useState(false)
|
const [isPending, setIsPending] = useState(false)
|
||||||
const [isWxWorkEnv, setIsWxWorkEnv] = useState(false)
|
const [isWxWorkEnv, setIsWxWorkEnv] = useState(false)
|
||||||
const [authOptions, setAuthOptions] = useState<AuthOptions>({
|
const [authOptions, setAuthOptions] = useState<AuthOptions | null>(null)
|
||||||
wxworkEnabled: false,
|
|
||||||
oidcEnabled: false,
|
|
||||||
})
|
|
||||||
const nextPath = searchParams.get("next")
|
const nextPath = searchParams.get("next")
|
||||||
const wxworkError = searchParams.get("wxworkError")
|
const wxworkError = searchParams.get("wxworkError")
|
||||||
const oidcError = searchParams.get("oidcError")
|
const oidcError = searchParams.get("oidcError")
|
||||||
const redirectPath =
|
const redirectPath =
|
||||||
nextPath && nextPath.startsWith("/") ? nextPath : "/dashboard"
|
nextPath && nextPath.startsWith("/") ? nextPath : "/dashboard"
|
||||||
const enabledProviderCount =
|
const enabledProviderCount =
|
||||||
Number(authOptions.wxworkEnabled) + Number(authOptions.oidcEnabled)
|
Number(authOptions?.wxworkEnabled) + Number(authOptions?.oidcEnabled)
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (session) {
|
if (session) {
|
||||||
@@ -115,6 +112,10 @@ export function LoginForm({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!authOptions) {
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
className={cn("flex flex-col gap-6", className)}
|
className={cn("flex flex-col gap-6", className)}
|
||||||
|
|||||||
Reference in New Issue
Block a user