import Image from 'next/image'; import Link from 'next/link'; import { SignInForm } from './sign-in-form'; export const metadata = { title: 'sign in', }; function describeError(code: string | undefined): string | null { if (!code) return null; // Map the most common Better Auth + provider error codes to human copy. // Default fallback: surface the code verbatim so an operator chasing // a regression can grep it. if (code.startsWith('oauth_')) { const provider = code.slice('oauth_'.length); return `the ${provider} sign-in didn't complete. this is usually a temporary issue — try again. if it keeps failing, check that your ${provider} app's authorized redirect URI matches https://api.briven.tech/v1/auth/callback/${provider}.`; } if (code === 'state_mismatch') { return 'the sign-in didn\'t complete because your browser blocked a cookie. try again in a private window, or check your browser settings.'; } return `sign-in failed (${code}). try again or use a different method.`; } export default async function SignInPage({ searchParams, }: { searchParams: Promise<{ next?: string; error?: string; deleted?: string }>; }) { const params = await searchParams; const next = params.next ?? '/dashboard'; const errorMessage = describeError(params.error); const justDeleted = params.deleted === '1'; // Public api origin — surfaced via NEXT_PUBLIC_BRIVEN_API_ORIGIN so the // signin form posts directly to it instead of going through Next.js's // /api/* rewrite (which proxy edges sometimes mangle). const apiOrigin = process.env.NEXT_PUBLIC_BRIVEN_API_ORIGIN ?? ''; // Each provider flag mirrors a server-side env: when the credentials // aren't configured, hide the button so users don't trigger a 500. const providers = { google: process.env.NEXT_PUBLIC_BRIVEN_HAS_GOOGLE_OAUTH === 'true', github: process.env.NEXT_PUBLIC_BRIVEN_HAS_GITHUB_OAUTH === 'true', discord: process.env.NEXT_PUBLIC_BRIVEN_HAS_DISCORD_OAUTH === 'true', // Git at code.konnos.org — platform genericOAuth (see apps/api/src/lib/auth.ts) konnos: process.env.NEXT_PUBLIC_BRIVEN_HAS_KONNOS_OAUTH === 'true', }; return (
briven

sign in

{errorMessage ? (
{errorMessage}
) : null} {justDeleted ? (

your account was deleted.

we've sent a confirmation to your inbox. you have 30 days to revert via support before the data is hard-deleted.

) : null}

by signing in you agree to the{' '} terms {' '} and{' '} privacy {' '} policy.

); }