Add Phase 0: sign-up, login, and profile
- Next.js (App Router) + TypeScript + Tailwind - Prisma + SQLite for the User model - Sign-up with 18+ age gate, email/password validation (zod), bcrypt hashing - Login via NextAuth credentials provider, JWT sessions - Protected /profile route (view + edit name/bio) Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VL5YUEf2B9LG4xdVUQwcSg
This commit is contained in:
27 files changed
+3196
No files matched your search
@@ -0,0 +1,35 @@
|
||||
import { getServerSession } from "next-auth";
|
||||
import { redirect } from "next/navigation";
|
||||
import { authOptions } from "@/lib/auth";
|
||||
import { prisma } from "@/lib/prisma";
|
||||
import ProfileEditor from "./profile-editor";
|
||||
import SignOutButton from "./sign-out-button";
|
||||
|
||||
export default async function ProfilePage() {
|
||||
const session = await getServerSession(authOptions);
|
||||
if (!session?.user?.id) {
|
||||
redirect("/login");
|
||||
}
|
||||
|
||||
const user = await prisma.user.findUnique({
|
||||
where: { id: session.user.id },
|
||||
select: { id: true, name: true, email: true, age: true, bio: true },
|
||||
});
|
||||
|
||||
if (!user) {
|
||||
redirect("/login");
|
||||
}
|
||||
|
||||
return (
|
||||
<main className="mx-auto flex min-h-screen max-w-sm flex-col justify-center gap-6 px-6 py-12">
|
||||
<div className="flex items-center justify-between">
|
||||
<h1 className="text-2xl font-bold text-brand">Your profile</h1>
|
||||
<SignOutButton />
|
||||
</div>
|
||||
<p className="text-sm text-gray-500">
|
||||
{user.email} · Age {user.age}
|
||||
</p>
|
||||
<ProfileEditor initialName={user.name} initialBio={user.bio} />
|
||||
</main>
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user