Files
sofa/app/(auth)/login/page.tsx
T
jakeandClaude Opus 4.6 3511a76508 Improve fresh install flow and auth page routing
- Move /setup out of protected (pages) route group so it's accessible
  without auth (fixes fresh install redirect loop)
- Redirect /login → /register when zero users exist
- Add "Get Started" button on landing page for fresh installs
- Hide register button/link when registration is closed
- Add auth redirects: logged-in users on /login or /register → /dashboard
- Convert register page to server component with server-side checks
- Fix animation snap on auth form buttons (transition-all → scoped)
- Update proxy middleware with /login and /register routes

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-04 13:58:15 -05:00

36 lines
1006 B
TypeScript

import { headers } from "next/headers";
import { redirect } from "next/navigation";
import { AuthForm } from "@/components/auth-form";
import { auth } from "@/lib/auth/server";
import {
getOidcProviderName,
isOidcConfigured,
isPasswordLoginDisabled,
} from "@/lib/config";
import { getUserCount, isRegistrationOpen } from "@/lib/services/settings";
export default async function LoginPage() {
const session = await auth.api.getSession({ headers: await headers() });
if (session) redirect("/dashboard");
if (getUserCount() === 0) {
redirect("/register");
}
const oidcEnabled = isOidcConfigured();
return (
<div className="flex min-h-[80vh] items-center justify-center px-4">
<AuthForm
mode="login"
authConfig={{
oidcEnabled,
oidcProviderName: oidcEnabled ? getOidcProviderName() : null,
passwordLoginDisabled: isPasswordLoginDisabled(),
registrationOpen: isRegistrationOpen(),
}}
/>
</div>
);
}