Invitation-only sign-up, invitation e-mails and waitlist
- SIGNUP_MODE=invite (default): a new account needs an open invitation for its address, or the invitation link (then any Google account will do) - admin page "Meghívók": invite many addresses at once, personal message, resend (max 3, 24 h apart), revoke, copy link, mail preview and test copy, waitlist - invitation e-mail in HTML and plain text; Message-ID on the sender's domain, List-Unsubscribe with one-click POST, opt-out list (hashes only) - e-mail texts moved to a shared crate (crates/email-templates) - login page shows the invitation; waitlist for uninvited visitors; unsubscribe page; privacy policy updated - docs/levelkuldes.md: Brevo, DNS (SPF, DKIM, DMARC) and the SMTP setup Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012vLHzh5qUhFtmJhzkcTbXL
This commit is contained in:
@@ -5,7 +5,8 @@ import { redirect } from "next/navigation";
|
||||
import { Logo } from "@/components/SiteHeader";
|
||||
import { ZodiacWheel } from "@/components/ZodiacWheel";
|
||||
import { BACKEND_URL, getMe } from "@/lib/server";
|
||||
import type { PublicConfig } from "@/lib/types";
|
||||
import { formatDate } from "@/lib/astro";
|
||||
import type { InvitationLanding, PublicConfig } from "@/lib/types";
|
||||
|
||||
import { GoogleLogin } from "./GoogleLogin";
|
||||
|
||||
@@ -26,11 +27,63 @@ async function loadConfig(): Promise<PublicConfig | null> {
|
||||
}
|
||||
}
|
||||
|
||||
async function loadInvitation(token: string): Promise<InvitationLanding | null> {
|
||||
try {
|
||||
const res = await fetch(`${BACKEND_URL}/v1/public/invitations/${encodeURIComponent(token)}`, { cache: "no-store" });
|
||||
return res.ok ? ((await res.json()) as InvitationLanding) : null;
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
const CLOSED: Record<string, string> = {
|
||||
accepted: "Ezt a meghívót már felhasználták. Ha a tiéd volt, egyszerűen lépj be ugyanazzal a Google-fiókkal.",
|
||||
expired: "Ez a meghívó lejárt. Kérj újat attól, aki meghívott.",
|
||||
revoked: "Ezt a meghívót visszavonták.",
|
||||
};
|
||||
|
||||
/** The invitation the visitor came with: who sent it and what they wrote. */
|
||||
function InvitationCard({ invitation }: { invitation: InvitationLanding | null }) {
|
||||
if (!invitation) {
|
||||
return (
|
||||
<p className="msg msg-error" role="alert">
|
||||
Ez a meghívólink érvénytelen. Ellenőrizd, hogy a teljes linket nyitottad-e meg a levélből.
|
||||
</p>
|
||||
);
|
||||
}
|
||||
if (invitation.status !== "pending") {
|
||||
return (
|
||||
<p className="msg msg-error" role="alert">
|
||||
{CLOSED[invitation.status]}
|
||||
</p>
|
||||
);
|
||||
}
|
||||
return (
|
||||
<div className="card invite-card">
|
||||
<span className="eyebrow">Meghívó</span>
|
||||
<p style={{ margin: 0 }}>
|
||||
{invitation.inviter_name ? <strong>{invitation.inviter_name}</strong> : "Valaki"} meghívott a Sorsfonalakra.
|
||||
</p>
|
||||
{invitation.message && <blockquote className="invite-quote">{invitation.message}</blockquote>}
|
||||
<p className="hint" style={{ margin: 0 }}>
|
||||
Bármelyik Google-fiókoddal elfogadhatod. Érvényes: {formatDate(invitation.expires_at).replace(/\.$/, "")}-ig.
|
||||
</p>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export default async function LoginPage({ searchParams }: { searchParams: Promise<Record<string, string | string[]>> }) {
|
||||
const target = safeTarget((await searchParams).vissza);
|
||||
const params = await searchParams;
|
||||
const target = safeTarget(params.vissza);
|
||||
if (await getMe()) redirect(target);
|
||||
const config = await loadConfig();
|
||||
const rawToken = Array.isArray(params.meghivo) ? params.meghivo[0] : params.meghivo;
|
||||
const inviteToken = rawToken && /^[A-Za-z0-9_-]{8,200}$/.test(rawToken) ? rawToken : null;
|
||||
const [config, invitation] = await Promise.all([
|
||||
loadConfig(),
|
||||
inviteToken ? loadInvitation(inviteToken) : Promise.resolve(null),
|
||||
]);
|
||||
const clientId = config?.google_login.enabled ? config.google_login.client_id : null;
|
||||
const inviteOnly = config?.signup_mode === "invite";
|
||||
|
||||
return (
|
||||
<div className="auth">
|
||||
@@ -47,21 +100,32 @@ export default async function LoginPage({ searchParams }: { searchParams: Promis
|
||||
<main className="auth-main">
|
||||
<div className="auth-box">
|
||||
<div className="page-head">
|
||||
<h1 style={{ fontSize: 44 }}>Belépés</h1>
|
||||
<p className="muted">Üdv újra! Lépj be a fiókodba.</p>
|
||||
<h1 style={{ fontSize: 44 }}>{rawToken ? "Meghívó" : "Belépés"}</h1>
|
||||
<p className="muted">{rawToken ? "Lépj be, és már kezdheted is." : "Üdv újra! Lépj be a fiókodba."}</p>
|
||||
</div>
|
||||
{rawToken && <InvitationCard invitation={inviteToken ? invitation : null} />}
|
||||
{config === null ? (
|
||||
<p className="msg msg-error" role="alert">
|
||||
A szerver most nem érhető el. Próbáld újra egy kicsit később.
|
||||
</p>
|
||||
) : clientId ? (
|
||||
<GoogleLogin clientId={clientId} target={target} />
|
||||
<GoogleLogin
|
||||
clientId={clientId}
|
||||
target={target}
|
||||
inviteToken={invitation?.status === "pending" ? inviteToken : null}
|
||||
/>
|
||||
) : (
|
||||
<p className="msg msg-error" role="alert">
|
||||
A Google-belépés még nincs beállítva (a backend <code>GOOGLE_CLIENT_IDS</code> változója üres).
|
||||
</p>
|
||||
)}
|
||||
<p className="auth-foot">Még nincs fiókod? Az első belépéskor létrejön.</p>
|
||||
<p className="auth-foot">
|
||||
{rawToken
|
||||
? "A fiókod az első belépéskor jön létre."
|
||||
: inviteOnly
|
||||
? "Az oldal jelenleg meghívásos: új fiók csak meghívóval jön létre."
|
||||
: "Még nincs fiókod? Az első belépéskor létrejön."}
|
||||
</p>
|
||||
<p className="hint">
|
||||
A belépéssel elfogadod, hogy a születési adataidat a képleted kiszámításához tároljuk. Bármikor törölheted
|
||||
őket a profilodban. Részletek: <Link href="/adatvedelem">adatvédelmi tájékoztató</Link>.
|
||||
|
||||
Reference in New Issue
Block a user