auth: e-mail + password login with e-mailed password links
Sign-up asks no password: a link goes to the address and the password is set there (also for forgotten passwords), by whoever opens the mailbox. So nobody can register a password for someone else's address, and linking Google or Apple to an account with the same address stays safe. Opening the link confirms the address, ends other sessions and logs in. Sign-up answers alike for registered addresses (the owner gets an 'account exists' link), links are limited to one per kind a minute and five an hour, and unconfirmed password accounts cannot log in. Frontend: login form with sign-up and forgotten password next to the social buttons, and the /jelszo page for the link. Still behind PASSWORD_LOGIN (off on prod). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012vLHzh5qUhFtmJhzkcTbXL
This commit is contained in:
@@ -10,6 +10,7 @@ import type { InvitationLanding, PublicConfig } from "@/lib/types";
|
||||
|
||||
import { AppleLogin } from "./AppleLogin";
|
||||
import { GoogleLogin } from "./GoogleLogin";
|
||||
import { PasswordLogin } from "./PasswordLogin";
|
||||
|
||||
export const metadata: Metadata = { title: "Belépés" };
|
||||
|
||||
@@ -48,7 +49,15 @@ const CLOSED: Record<string, string> = {
|
||||
};
|
||||
|
||||
/** The invitation the visitor came with: who sent it and what they wrote. */
|
||||
function InvitationCard({ invitation, apple }: { invitation: InvitationLanding | null; apple: boolean }) {
|
||||
function InvitationCard({
|
||||
invitation,
|
||||
apple,
|
||||
password,
|
||||
}: {
|
||||
invitation: InvitationLanding | null;
|
||||
apple: boolean;
|
||||
password: boolean;
|
||||
}) {
|
||||
if (!invitation) {
|
||||
return (
|
||||
<p className="msg msg-error" role="alert">
|
||||
@@ -71,7 +80,9 @@ function InvitationCard({ invitation, apple }: { invitation: InvitationLanding |
|
||||
</p>
|
||||
{invitation.message && <blockquote className="invite-quote">{invitation.message}</blockquote>}
|
||||
<p className="hint" style={{ margin: 0 }}>
|
||||
Bármelyik {apple ? "Google- vagy Apple-fiókoddal" : "Google-fiókoddal"} elfogadhatod. Érvényes: {formatDate(invitation.expires_at).replace(/\.$/, "")}-ig.
|
||||
Bármelyik {apple ? "Google- vagy Apple-fiókoddal" : "Google-fiókoddal"}
|
||||
{password ? ", vagy e-mail-címmel regisztrálva" : ""} elfogadhatod. Érvényes:{" "}
|
||||
{formatDate(invitation.expires_at).replace(/\.$/, "")}-ig.
|
||||
</p>
|
||||
</div>
|
||||
);
|
||||
@@ -91,6 +102,9 @@ export default async function LoginPage({ searchParams }: { searchParams: Promis
|
||||
const appleId = config?.apple_login?.enabled ? config.apple_login.client_id : null;
|
||||
const pendingInvite = invitation?.status === "pending" ? inviteToken : null;
|
||||
const inviteOnly = config?.signup_mode === "invite";
|
||||
const password = config?.password_login === true;
|
||||
const mod = Array.isArray(params.mod) ? params.mod[0] : params.mod;
|
||||
const initialMode = mod === "elfelejtett" ? "forgot" : mod === "regisztracio" || rawToken ? "register" : "login";
|
||||
|
||||
return (
|
||||
<div className="auth">
|
||||
@@ -114,16 +128,28 @@ export default async function LoginPage({ searchParams }: { searchParams: Promis
|
||||
<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} apple={appleId !== null} />}
|
||||
{rawToken && (
|
||||
<InvitationCard invitation={inviteToken ? invitation : null} apple={appleId !== null} password={password} />
|
||||
)}
|
||||
{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 ? (
|
||||
<div className="field" style={{ gap: 12 }}>
|
||||
<GoogleLogin clientId={clientId} target={target} inviteToken={pendingInvite} />
|
||||
{appleId && <AppleLogin clientId={appleId} target={target} inviteToken={pendingInvite} />}
|
||||
</div>
|
||||
) : clientId || password ? (
|
||||
<>
|
||||
{clientId && (
|
||||
<div className="field" style={{ gap: 12 }}>
|
||||
<GoogleLogin clientId={clientId} target={target} inviteToken={pendingInvite} />
|
||||
{appleId && <AppleLogin clientId={appleId} target={target} inviteToken={pendingInvite} />}
|
||||
</div>
|
||||
)}
|
||||
{clientId && password && (
|
||||
<div className="auth-or" role="separator">
|
||||
<span>vagy</span>
|
||||
</div>
|
||||
)}
|
||||
{password && <PasswordLogin target={target} inviteToken={pendingInvite} initialMode={initialMode} />}
|
||||
</>
|
||||
) : (
|
||||
<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).
|
||||
@@ -134,7 +160,9 @@ export default async function LoginPage({ searchParams }: { searchParams: Promis
|
||||
? "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."}
|
||||
: password
|
||||
? "Google- vagy Apple-fiókkal az első belépéskor létrejön a fiókod."
|
||||
: "Még nincs fiókod? Az első belépéskor létrejön."}
|
||||
</p>
|
||||
<p className="hint">
|
||||
A belépéssel elfogadod az <Link href="/aszf">általános szerződési feltételeket</Link>, és hogy a születési
|
||||
|
||||
Reference in New Issue
Block a user