Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 22 additions & 1 deletion web/app/auth/signin/page.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,28 @@
import { Suspense } from 'react';
import { redirect } from 'next/navigation';
import SignInForm from './form';
import { loadConsoleProfile } from '@/lib/services/console-profile';

export const dynamic = 'force-dynamic';

export default async function SignIn({
searchParams,
}: {
searchParams: Promise<{ next?: string }>;
}) {
// Auth guard: an already-signed-in user should never sit on the sign-in
// screen. On mobile the device Back button pops history to /auth/signin
// (the OAuth flow leaves it on the stack), which read as "Back dumps me at
// sign-in". Bounce authenticated users forward into the app instead, so Back
// effectively returns them to the console.
const profile = await loadConsoleProfile();
if (profile) {
const { next } = await searchParams;
// Only honour app-internal paths to avoid an open-redirect via ?next=.
const dest = next && next.startsWith('/') && !next.startsWith('//') ? next : '/dashboard';

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prefer using an optional chain expression instead, as it's more concise and easier to read


The optional chaining operator can be used to perform null checks before accessing a property, or calling a function.

redirect(dest);
}

export default function SignIn() {
return (
<Suspense fallback={<div style={{ display: "flex", minHeight: "100vh", alignItems: "center", justifyContent: "center", background: "var(--void)", color: "var(--ink-muted)", fontFamily: "var(--font-mono)", fontSize: 12, letterSpacing: "0.08em", textTransform: "uppercase" as const }}>Loading...</div>}>
<SignInForm />
Expand Down
Loading