Fixed AI Auto Launch, Fixed Client Login not working
Build & Auto-Repair / build (push) Has been cancelled
Build & Auto-Repair / build (push) Has been cancelled
This commit is contained in:
+17
-4
@@ -42,9 +42,17 @@ function LoginForm() {
|
||||
|
||||
useEffect(() => {
|
||||
fetch("/api/auth/me", { credentials: "include" })
|
||||
.then((r) => {
|
||||
if (r.ok) router.push("/dashboard")
|
||||
else setCheckingSession(false)
|
||||
.then(async (r) => {
|
||||
if (r.ok) {
|
||||
const data = await r.json().catch(() => ({}))
|
||||
if (data.user?.role === "client") {
|
||||
window.location.href = "/client-portal/dashboard"
|
||||
} else {
|
||||
router.push("/dashboard")
|
||||
}
|
||||
} else {
|
||||
setCheckingSession(false)
|
||||
}
|
||||
})
|
||||
.catch(() => setCheckingSession(false))
|
||||
}, [router])
|
||||
@@ -239,11 +247,16 @@ function LoginForm() {
|
||||
})
|
||||
|
||||
if (res.ok) {
|
||||
const loginData = await res.json().catch(() => ({}))
|
||||
localStorage.removeItem(WEBSITE_THEME_KEY)
|
||||
const root = document.documentElement
|
||||
root.className = root.className.split(" ").filter((c) => !c.startsWith("theme-")).join(" ").trim()
|
||||
const redirectTo = searchParams.get("redirect") || "/dashboard"
|
||||
router.push(redirectTo)
|
||||
if (loginData.user?.role === "client") {
|
||||
window.location.href = "/client-portal/dashboard"
|
||||
} else {
|
||||
router.push(redirectTo)
|
||||
}
|
||||
} else {
|
||||
const data = await res.json().catch(() => ({}))
|
||||
setError(data.error || "Invalid email or password.")
|
||||
|
||||
Reference in New Issue
Block a user