Fixed AI Auto Launch, Fixed Client Login not working
Build & Auto-Repair / build (push) Has been cancelled

This commit is contained in:
JCBSComputer
2026-07-01 16:36:48 +02:00
parent 7606af04ab
commit 4a33ca0368
4 changed files with 43 additions and 8 deletions
+1 -1
View File
@@ -20,7 +20,7 @@
"repair:ci": "node scripts/code-repair-agent.mjs --ci",
"build:fix": "npm run build 2>&1 || node scripts/code-repair-agent.mjs --ci",
"build": "next build",
"start": "next start -p 3006",
"start": "node scripts/ensure-ollama.mjs && concurrently -n AI,NEXT -c cyan,green \"npm run dev:rust\" \"next start -p 3006\"",
"lint": "eslint"
},
"dependencies": {
+23 -1
View File
@@ -14,16 +14,26 @@ export default function ClientLoginPage() {
const [checking, setChecking] = useState(true)
const [debugInfo, setDebugInfo] = useState("")
const [sessionUser, setSessionUser] = useState<{ email: string; role: string } | null>(null)
useEffect(() => {
fetch("/api/auth/me", { credentials: "include" })
.then((r) => r.json())
.then((data) => {
if (data.user?.role === "client") router.push("/client-portal/dashboard")
else setChecking(false)
else {
if (data.user) setSessionUser({ email: data.user.email, role: data.user.role })
setChecking(false)
}
})
.catch(() => setChecking(false))
}, [router])
const handleSignOut = async () => {
await fetch("/api/auth/logout", { method: "POST" })
setSessionUser(null)
}
const handleSubmit = async (e: React.FormEvent) => {
e.preventDefault()
setLoading(true)
@@ -83,6 +93,18 @@ export default function ClientLoginPage() {
<p className="text-sm text-muted-foreground">Sign in to view your projects and invoices</p>
</div>
{sessionUser && (
<div className="mb-4 bg-card border border-border rounded-lg p-3 flex items-center justify-between">
<div className="text-xs text-muted-foreground">
Signed in as <span className="text-foreground font-medium">{sessionUser.email}</span>
<span className="ml-1.5 text-[10px] px-1.5 py-0.5 rounded bg-primary/10 text-primary uppercase">{(sessionUser.role || "").replace("_", " ")}</span>
</div>
<button onClick={handleSignOut} className="text-xs text-destructive hover:text-destructive/80 font-medium">
Sign Out
</button>
</div>
)}
<form onSubmit={handleSubmit} className="space-y-4">
<div>
<label className="block text-sm text-muted-foreground mb-1.5">Email</label>
+17 -4
View File
@@ -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.")
+2 -2
View File
@@ -187,8 +187,8 @@ export const AIChat = forwardRef<{ fillInput: (text: string) => void }, AIChatPr
}, [])
useEffect(() => {
checkServer()
}, [checkServer])
setBootState("ready")
}, [])
useEffect(() => {
messagesEndRef.current?.scrollIntoView({ behavior: "smooth" })