fix(auth): use full-page navigation after sign-in to prevent stale dashboard
CI / Architecture Guardrails (push) Failing after 2m25s
CI / Lint (push) Has been cancelled
CI / Unit Tests (push) Has been cancelled
CI / Typecheck (push) Has started running
CI / Assistant Split Regression (push) Has started running
CI / Build (push) Has been cancelled
CI / E2E Tests (push) Has been cancelled
Release Image / Build And Push Images (push) Has been cancelled
Docker Deploy Test / Fresh-Linux Docker Deploy (push) Has been cancelled

router.refresh() + router.push() left the React tree (incl. QueryClient
with staleTime: 60_000 and cached pre-auth query errors) and the Next.js
Router Cache alive across the login boundary. This caused the recurring
bug where the dashboard rendered with empty widgets until the user
pressed Ctrl+R. A full-page navigation guarantees a fresh server request
with the new session cookie and a clean client state.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-04-12 10:00:07 +02:00
parent 622c4135f5
commit dc1e0bfb28
+25 -11
View File
@@ -59,10 +59,15 @@ export default function SignInPage() {
setTotp("");
}
} else {
// Invalidate the Next.js Router Cache so (app)/layout.tsx re-renders
// with the fresh session, then navigate to the dashboard.
router.refresh();
router.push("/dashboard");
// Full-page navigation instead of router.push to guarantee a fresh
// server request with the new session cookie. Soft navigation keeps
// the React tree (incl. QueryClient with cached pre-auth errors and
// the Next.js Router Cache) alive, which caused the recurring bug
// where the dashboard rendered with empty widgets until the user
// pressed Ctrl+R. Skipping setLoading(false) prevents a visual flash
// while the navigation happens.
window.location.assign("/dashboard");
return;
}
setLoading(false);
@@ -86,21 +91,28 @@ export default function SignInPage() {
Resource planning that stays readable under pressure.
</h1>
<p className="mt-5 max-w-xl text-lg text-gray-600 dark:text-gray-300">
Estimates, staffing, chargeability, and timelines in one workspace with sharper structure for day-to-day planning.
Estimates, staffing, chargeability, and timelines in one workspace with sharper
structure for day-to-day planning.
</p>
</div>
<div className="grid gap-4 sm:grid-cols-3">
<div className="app-surface p-5">
<p className="app-label">Visibility</p>
<p className="text-sm text-gray-700 dark:text-gray-300">Clearer data density, stronger contrast, faster scanning.</p>
<p className="text-sm text-gray-700 dark:text-gray-300">
Clearer data density, stronger contrast, faster scanning.
</p>
</div>
<div className="app-surface p-5">
<p className="app-label">Planning</p>
<p className="text-sm text-gray-700 dark:text-gray-300">Dynamic staffing, resources, and chargeability in one flow.</p>
<p className="text-sm text-gray-700 dark:text-gray-300">
Dynamic staffing, resources, and chargeability in one flow.
</p>
</div>
<div className="app-surface p-5">
<p className="app-label">Control</p>
<p className="text-sm text-gray-700 dark:text-gray-300">Theme-aware UI that works in bright and dark environments.</p>
<p className="text-sm text-gray-700 dark:text-gray-300">
Theme-aware UI that works in bright and dark environments.
</p>
</div>
</div>
</div>
@@ -108,7 +120,9 @@ export default function SignInPage() {
<div className="w-full max-w-md lg:ml-auto lg:max-w-lg">
<div className="app-surface-strong p-8">
<div className="mb-8">
<p className="text-xs font-semibold uppercase tracking-[0.18em] text-brand-600">Welcome Back</p>
<p className="text-xs font-semibold uppercase tracking-[0.18em] text-brand-600">
Welcome Back
</p>
<h2 className="mt-3 font-display text-4xl font-semibold text-gray-900 dark:text-gray-50">
{mfaRequired ? "Two-Factor Authentication" : "Sign in to CapaKraken"}
</h2>
@@ -189,7 +203,8 @@ export default function SignInPage() {
required
/>
<p className="mt-2 text-xs text-gray-500 dark:text-gray-400">
Open your authenticator app (e.g. Google Authenticator, Authy) and enter the current code.
Open your authenticator app (e.g. Google Authenticator, Authy) and enter the
current code.
</p>
</div>
)}
@@ -212,7 +227,6 @@ export default function SignInPage() {
</button>
)}
</form>
</div>
</div>
</div>