Members register via email+password (scrypt) or Google OAuth — same signed-cookie + scrypt pattern as LokiLab (lib/auth.ts, member-password.ts, member-auth.ts, google-oauth.ts), own AUTH_SECRET and own OAuth client, own dedicated Postgres database (lokiloto-db on Coolify), fully isolated from LokiLab's own DB and auth. Leaderboard tracks who follows Loki's picks most accurately — members star a pick from the results panel (FollowButton), resolution reuses LokiLab's own lastDraw.won, no money or pooled play involved anywhere. Leaderboard page renders a horizontal bar chart (recharts) plus a ranked list. Profile page: public nickname (required to appear on the leaderboard), list of followed picks. Header now carries nav + a user menu (avatar dropdown when signed in, "Connexion" button otherwise). Dockerfile runs prisma migrate deploy at container start via docker-entrypoint.sh, same pattern as LokiLab. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
26 lines
853 B
TypeScript
26 lines
853 B
TypeScript
"use server"
|
|
|
|
import { z } from "zod"
|
|
import { revalidatePath } from "next/cache"
|
|
import { prisma } from "@/lib/db"
|
|
import { getCurrentMember } from "@/lib/member-auth"
|
|
|
|
const nicknameSchema = z.string().trim().min(2).max(24)
|
|
|
|
export interface NicknameState {
|
|
ok: boolean
|
|
message: string
|
|
}
|
|
|
|
export async function setNicknameAction(_prev: NicknameState, formData: FormData): Promise<NicknameState> {
|
|
const member = await getCurrentMember()
|
|
if (!member) return { ok: false, message: "Non connecté." }
|
|
|
|
const parsed = nicknameSchema.safeParse(formData.get("nickname"))
|
|
if (!parsed.success) return { ok: false, message: "Pseudo invalide (2 à 24 caractères)." }
|
|
|
|
await prisma.user.update({ where: { id: member.id }, data: { publicNickname: parsed.data } })
|
|
revalidatePath("/profil")
|
|
return { ok: true, message: "Pseudo mis à jour." }
|
|
}
|