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>
91 lines
3.7 KiB
TypeScript
91 lines
3.7 KiB
TypeScript
import type { Metadata } from "next"
|
|
import Link from "next/link"
|
|
import { redirect } from "next/navigation"
|
|
import { getCurrentMember } from "@/lib/member-auth"
|
|
import { MemberAuthForm } from "@/components/member-auth-form"
|
|
import { LokiMark } from "@/components/loki-mark"
|
|
|
|
export const metadata: Metadata = { title: "Connexion — LokiLoto" }
|
|
export const instant = false
|
|
|
|
const ERROR_FR: Record<string, string> = {
|
|
oauth_state: "La connexion a expiré ou a été interrompue. Réessayez.",
|
|
oauth_failed: "La connexion avec Google a échoué. Réessayez.",
|
|
google_not_configured: "La connexion Google n'est pas encore activée sur ce site.",
|
|
}
|
|
|
|
export default async function LoginPage({
|
|
searchParams,
|
|
}: {
|
|
searchParams: Promise<Record<string, string | string[] | undefined>>
|
|
}) {
|
|
const member = await getCurrentMember()
|
|
if (member) redirect("/profil")
|
|
|
|
const sp = await searchParams
|
|
const errorKey = typeof sp.error === "string" ? sp.error : null
|
|
const error = errorKey ? (ERROR_FR[errorKey] ?? "Une erreur est survenue. Réessayez.") : null
|
|
const next = typeof sp.next === "string" && sp.next.startsWith("/") ? sp.next : "/profil"
|
|
|
|
return (
|
|
<main className="flex flex-1 items-center justify-center px-4 py-12">
|
|
<div className="w-full max-w-sm">
|
|
<Link href="/" className="mb-8 inline-flex items-center gap-2">
|
|
<LokiMark className="h-8 w-8 text-accent" />
|
|
<span className="text-lg font-bold tracking-tight">LokiLoto</span>
|
|
</Link>
|
|
|
|
<h1 className="text-xl font-bold tracking-tight">Connexion</h1>
|
|
<p className="mt-1 text-sm text-muted-foreground">
|
|
Suivez les choix de Loki, apparaissez au classement, gardez votre pays favori.
|
|
</p>
|
|
|
|
{error && <p className="mt-4 text-xs text-destructive">{error}</p>}
|
|
|
|
<div className="mt-6">
|
|
<MemberAuthForm next={next} />
|
|
</div>
|
|
|
|
<div className="my-5 flex items-center gap-3 text-[11px] text-muted-foreground">
|
|
<span className="h-px flex-1 bg-border" />
|
|
ou
|
|
<span className="h-px flex-1 bg-border" />
|
|
</div>
|
|
|
|
<a
|
|
href={`/api/auth/google?next=${encodeURIComponent(next)}`}
|
|
className="flex h-9 w-full items-center justify-center gap-3 rounded-md border border-border bg-panel text-sm font-medium transition-colors hover:bg-panel-hover"
|
|
>
|
|
<svg viewBox="0 0 24 24" className="h-4 w-4 shrink-0" aria-hidden="true">
|
|
<path
|
|
fill="#4285F4"
|
|
d="M23.52 12.27c0-.85-.07-1.47-.23-2.12H12v3.85h6.6c-.13 1.1-.86 2.76-2.47 3.87l-.02.15 3.59 2.78.25.02c2.28-2.1 3.57-5.2 3.57-8.55"
|
|
/>
|
|
<path
|
|
fill="#34A853"
|
|
d="M12 24c3.24 0 5.95-1.07 7.93-2.91l-3.78-2.93c-1.02.7-2.4 1.19-4.15 1.19-3.18 0-5.88-2.1-6.84-5l-.14.01-3.73 2.89-.05.13C3.21 21.3 7.26 24 12 24"
|
|
/>
|
|
<path
|
|
fill="#FBBC05"
|
|
d="M5.16 14.35A7.3 7.3 0 0 1 4.75 12c0-.81.14-1.6.4-2.35l-.01-.16-3.78-2.94-.12.06A11.97 11.97 0 0 0 0 12c0 1.93.46 3.76 1.24 5.39l3.92-3.04"
|
|
/>
|
|
<path
|
|
fill="#EA4335"
|
|
d="M12 4.75c2.25 0 3.77.97 4.64 1.78l3.39-3.31C17.94 1.19 15.24 0 12 0 7.26 0 3.21 2.7 1.24 6.61l3.91 3.04c.97-2.9 3.67-5 6.85-5"
|
|
/>
|
|
</svg>
|
|
Continuer avec Google
|
|
</a>
|
|
|
|
<p className="mt-6 text-[11px] leading-relaxed text-muted-foreground">
|
|
Un compte LokiLoto sert à suivre vos pronostics et apparaître au classement. Aucun billet
|
|
n'est vendu, aucun argent ne transite par ce site.
|
|
</p>
|
|
<Link href="/" className="mt-6 inline-block text-xs text-muted-foreground hover:text-foreground">
|
|
← Retour au site
|
|
</Link>
|
|
</div>
|
|
</main>
|
|
)
|
|
}
|