Refactor auth session handling and server actions across app

- Overhaul `lib/auth/server.ts` and `lib/auth/session.ts`; update all API
  routes and server actions to use the revised session pattern
- Refactor server actions (settings, titles, watchlist, setup) for
  consistency with new auth layer
- Extract `SetupForm` into its own client component with `useActionState`,
  animated steps, and copyable env snippets
- Move landing page redirect logic into `app/page.tsx`; slim down
  `LandingPage` component
- Add `proxy.ts` for local dev proxying
- Minor cleanup to `NavBar`, `MobileTabBar`, and `TitleCard`
This commit is contained in:
2026-03-06 17:05:49 -05:00
parent 7a3052250d
commit 73b07f5ff6
34 changed files with 443 additions and 466 deletions
-32
View File
@@ -3,22 +3,7 @@
import { motion } from "motion/react";
import Image from "next/image";
import Link from "next/link";
import { useRouter } from "next/navigation";
import { useEffect } from "react";
import { SofaLogo } from "@/components/sofa-logo";
import { useSession } from "@/lib/auth/client";
/** Check whether the server has TMDB configured. */
async function fetchSetupStatus(): Promise<boolean> {
try {
const res = await fetch("/api/setup/status");
if (!res.ok) return true; // assume configured on error
const data = await res.json();
return !!data.tmdbConfigured;
} catch {
return true;
}
}
// Poster positions arranged in angled columns behind the hero
const posterLayout = [
@@ -49,23 +34,6 @@ export function LandingPage({
freshInstall: boolean;
registrationOpen: boolean;
}) {
const { data: session, isPending } = useSession();
const router = useRouter();
useEffect(() => {
if (isPending) return;
if (session?.user) {
router.replace("/dashboard");
return;
}
// If not logged in, check whether TMDB is configured
fetchSetupStatus().then((configured) => {
if (!configured) router.replace("/setup");
});
}, [session, isPending, router]);
if (isPending) return null;
return (
<div className="relative flex min-h-screen flex-col items-center justify-center overflow-hidden">
{/* Background grain texture */}