feat: add editorial registration and authentication
This commit is contained in:
1 parent
7acaacb92e
commit
9b22752ef2
20 files changed
+1728
-20
No files matched your search
@@ -0,0 +1,38 @@
|
||||
import Link from "next/link";
|
||||
|
||||
import { env } from "@/config/env";
|
||||
import { LoginForm } from "@/modules/auth/public-forms";
|
||||
|
||||
export default function LoginPage() {
|
||||
return (
|
||||
<main className="public-account-page">
|
||||
<header className="masthead">
|
||||
<Link className="wordmark" href="/">
|
||||
Leon Tonhäuser
|
||||
</Link>
|
||||
<span className="section-label">Redaktionsportal</span>
|
||||
</header>
|
||||
<section className="account-panel" aria-labelledby="login-title">
|
||||
<p className="eyebrow">Zugang</p>
|
||||
<h1 id="login-title">Anmelden</h1>
|
||||
<p className="lede">Melden Sie sich mit der E-Mail-Adresse Ihrer Redaktion an.</p>
|
||||
<LoginForm />
|
||||
<nav className="account-links" aria-label="Zugang verwalten">
|
||||
<Link href="/passwort-vergessen">Passwort vergessen?</Link>
|
||||
<Link href="/registrieren">Neue Redaktion registrieren</Link>
|
||||
</nav>
|
||||
</section>
|
||||
<LegalFooter imprint={env.LEGAL_IMPRINT_URL} privacy={env.LEGAL_PRIVACY_URL} terms={env.LEGAL_TERMS_URL} />
|
||||
</main>
|
||||
);
|
||||
}
|
||||
|
||||
function LegalFooter({ imprint, privacy, terms }: { imprint: string; privacy: string; terms: string }) {
|
||||
return (
|
||||
<footer className="public-footer">
|
||||
<a href={imprint}>Impressum</a>
|
||||
<a href={privacy}>Datenschutz</a>
|
||||
<a href={terms}>Nutzungsbedingungen</a>
|
||||
</footer>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
import Link from "next/link";
|
||||
|
||||
import { PasswordResetRequestForm } from "@/modules/auth/public-forms";
|
||||
|
||||
export default function ForgotPasswordPage() {
|
||||
return (
|
||||
<main className="public-account-page">
|
||||
<header className="masthead">
|
||||
<Link className="wordmark" href="/">
|
||||
Leon Tonhäuser
|
||||
</Link>
|
||||
<span className="section-label">Redaktionsportal</span>
|
||||
</header>
|
||||
<section className="account-panel" aria-labelledby="forgot-password-title">
|
||||
<p className="eyebrow">Zugang</p>
|
||||
<h1 id="forgot-password-title">Passwort vergessen?</h1>
|
||||
<p className="lede">Fordern Sie einen Link zum Zurücksetzen Ihres Passworts an.</p>
|
||||
<PasswordResetRequestForm />
|
||||
<nav className="account-links" aria-label="Zurück zur Anmeldung">
|
||||
<Link href="/anmelden">Zur Anmeldung</Link>
|
||||
</nav>
|
||||
</section>
|
||||
</main>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
import Link from "next/link";
|
||||
|
||||
import { PasswordResetForm } from "@/modules/auth/public-forms";
|
||||
|
||||
export default async function ResetPasswordPage({
|
||||
searchParams,
|
||||
}: {
|
||||
searchParams: Promise<{ token?: string }>;
|
||||
}) {
|
||||
const { token } = await searchParams;
|
||||
|
||||
return (
|
||||
<main className="public-account-page">
|
||||
<header className="masthead">
|
||||
<Link className="wordmark" href="/">
|
||||
Leon Tonhäuser
|
||||
</Link>
|
||||
<span className="section-label">Redaktionsportal</span>
|
||||
</header>
|
||||
<section className="account-panel" aria-labelledby="reset-password-title">
|
||||
<p className="eyebrow">Zugang</p>
|
||||
<h1 id="reset-password-title">Neues Passwort setzen</h1>
|
||||
<p className="lede">Wählen Sie ein neues Passwort für den Zugang Ihrer Redaktion.</p>
|
||||
<PasswordResetForm token={token} />
|
||||
<nav className="account-links" aria-label="Zurück zur Anmeldung">
|
||||
<Link href="/anmelden">Zur Anmeldung</Link>
|
||||
</nav>
|
||||
</section>
|
||||
</main>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
import Link from "next/link";
|
||||
|
||||
export default function RegistrationConfirmedPage() {
|
||||
return (
|
||||
<main className="public-account-page">
|
||||
<header className="masthead">
|
||||
<Link className="wordmark" href="/">
|
||||
Leon Tonhäuser
|
||||
</Link>
|
||||
<span className="section-label">Redaktionsportal</span>
|
||||
</header>
|
||||
<section className="account-panel" aria-labelledby="confirmation-title">
|
||||
<p className="eyebrow">Registrierung</p>
|
||||
<h1 id="confirmation-title">Vielen Dank.</h1>
|
||||
<p className="lede">
|
||||
Bitte folgen Sie den weiteren Hinweisen, die wir Ihnen gegebenenfalls zusenden. Danach
|
||||
prüfen wir Ihre Registrierung.
|
||||
</p>
|
||||
<Link className="primary-action" href="/anmelden">
|
||||
Zur Anmeldung
|
||||
</Link>
|
||||
</section>
|
||||
</main>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
import Link from "next/link";
|
||||
import { redirect } from "next/navigation";
|
||||
|
||||
import { env } from "@/config/env";
|
||||
import { registerEditorial } from "@/modules/auth/auth";
|
||||
import { RegistrationValidationError } from "@/modules/auth/registration";
|
||||
import {
|
||||
RegistrationForm,
|
||||
type RegistrationFormState,
|
||||
} from "@/modules/auth/public-forms";
|
||||
|
||||
export default function RegistrationPage() {
|
||||
return (
|
||||
<main className="public-account-page">
|
||||
<header className="masthead">
|
||||
<Link className="wordmark" href="/">
|
||||
Leon Tonhäuser
|
||||
</Link>
|
||||
<span className="section-label">Redaktionsportal</span>
|
||||
</header>
|
||||
<section className="account-panel account-panel-wide" aria-labelledby="registration-title">
|
||||
<p className="eyebrow">B2B-Zugang</p>
|
||||
<h1 id="registration-title">Redaktion registrieren</h1>
|
||||
<p className="lede">
|
||||
Das Redaktionsportal steht ausschließlich Unternehmen und Redaktionen zur Verfügung.
|
||||
</p>
|
||||
<RegistrationForm
|
||||
action={registerAction}
|
||||
legalUrls={{
|
||||
imprint: env.LEGAL_IMPRINT_URL,
|
||||
privacy: env.LEGAL_PRIVACY_URL,
|
||||
terms: env.LEGAL_TERMS_URL,
|
||||
}}
|
||||
/>
|
||||
</section>
|
||||
</main>
|
||||
);
|
||||
}
|
||||
|
||||
async function registerAction(
|
||||
_state: RegistrationFormState,
|
||||
formData: FormData,
|
||||
): Promise<RegistrationFormState> {
|
||||
"use server";
|
||||
|
||||
try {
|
||||
await registerEditorial({
|
||||
companyName: text(formData, "companyName"),
|
||||
contactName: text(formData, "contactName"),
|
||||
email: text(formData, "email"),
|
||||
password: text(formData, "password"),
|
||||
billingAddress: {
|
||||
addressLine1: text(formData, "addressLine1"),
|
||||
addressLine2: text(formData, "addressLine2") || undefined,
|
||||
postalCode: text(formData, "postalCode"),
|
||||
city: text(formData, "city"),
|
||||
countryCode: text(formData, "countryCode"),
|
||||
},
|
||||
actsForBusiness: formData.has("actsForBusiness"),
|
||||
termsVersion: formData.has("termsAccepted") ? text(formData, "termsVersion") : "",
|
||||
privacyAcknowledged: formData.has("privacyAcknowledged"),
|
||||
});
|
||||
} catch (error) {
|
||||
if (error instanceof RegistrationValidationError) {
|
||||
return { errors: { [error.field]: error.message } };
|
||||
}
|
||||
}
|
||||
|
||||
redirect("/registrieren/bestaetigt");
|
||||
}
|
||||
|
||||
function text(formData: FormData, name: string): string {
|
||||
const value = formData.get(name);
|
||||
return typeof value === "string" ? value : "";
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
import { toNextJsHandler } from "better-auth/next-js";
|
||||
|
||||
import { auth } from "@/modules/auth/auth";
|
||||
|
||||
export const { GET, POST } = toNextJsHandler(auth);
|
||||
@@ -138,3 +138,141 @@ a {
|
||||
transition: none;
|
||||
}
|
||||
}
|
||||
|
||||
.public-account-page {
|
||||
display: grid;
|
||||
min-height: 100vh;
|
||||
grid-template-rows: auto 1fr auto;
|
||||
padding: clamp(1.25rem, 3vw, 2.75rem);
|
||||
}
|
||||
|
||||
.account-panel {
|
||||
width: min(100%, 37rem);
|
||||
align-self: center;
|
||||
padding-block: clamp(4rem, 10vh, 7rem);
|
||||
}
|
||||
|
||||
.account-panel-wide {
|
||||
width: min(100%, 48rem);
|
||||
}
|
||||
|
||||
.account-panel h1 {
|
||||
max-width: 12ch;
|
||||
margin: 0;
|
||||
font-size: clamp(2.6rem, 6vw, 5.5rem);
|
||||
font-weight: 600;
|
||||
letter-spacing: -0.06em;
|
||||
line-height: 0.92;
|
||||
}
|
||||
|
||||
.account-panel .lede {
|
||||
margin-top: 1.75rem;
|
||||
}
|
||||
|
||||
.account-form {
|
||||
display: grid;
|
||||
gap: 1.25rem;
|
||||
margin-top: 2.5rem;
|
||||
}
|
||||
|
||||
.account-form label,
|
||||
.acknowledgements legend {
|
||||
display: grid;
|
||||
gap: 0.5rem;
|
||||
font-size: 0.8125rem;
|
||||
font-weight: 650;
|
||||
letter-spacing: 0.01em;
|
||||
}
|
||||
|
||||
.account-form input:not([type="checkbox"]) {
|
||||
width: 100%;
|
||||
min-height: 3.1rem;
|
||||
border: 1px solid var(--ink);
|
||||
border-radius: 0;
|
||||
background: var(--paper);
|
||||
color: var(--ink);
|
||||
font: inherit;
|
||||
font-weight: 400;
|
||||
padding: 0.75rem;
|
||||
}
|
||||
|
||||
.form-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
gap: 1rem;
|
||||
}
|
||||
|
||||
.acknowledgements {
|
||||
display: grid;
|
||||
gap: 0.75rem;
|
||||
margin: 0;
|
||||
padding: 1.25rem 0;
|
||||
border: 0;
|
||||
border-top: 1px solid var(--line);
|
||||
border-bottom: 1px solid var(--line);
|
||||
}
|
||||
|
||||
.acknowledgements legend {
|
||||
padding: 0;
|
||||
margin-bottom: 0.25rem;
|
||||
}
|
||||
|
||||
.checkbox-label {
|
||||
grid-template-columns: 1rem minmax(0, 1fr);
|
||||
align-items: start;
|
||||
font-weight: 400 !important;
|
||||
line-height: 1.45;
|
||||
}
|
||||
|
||||
.checkbox-label input {
|
||||
width: 1rem;
|
||||
height: 1rem;
|
||||
margin: 0.12rem 0 0;
|
||||
accent-color: var(--ink);
|
||||
}
|
||||
|
||||
.checkbox-label a,
|
||||
.account-links a,
|
||||
.public-footer a,
|
||||
.legal-link {
|
||||
text-underline-offset: 0.17em;
|
||||
}
|
||||
|
||||
.field-error {
|
||||
margin: -0.25rem 0 0;
|
||||
color: #9d0e0e;
|
||||
font-size: 0.875rem;
|
||||
line-height: 1.4;
|
||||
}
|
||||
|
||||
.form-note {
|
||||
max-width: 44rem;
|
||||
margin: 0;
|
||||
color: var(--muted);
|
||||
font-size: 0.875rem;
|
||||
line-height: 1.55;
|
||||
}
|
||||
|
||||
.account-links,
|
||||
.public-footer {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 0.75rem 1.25rem;
|
||||
margin-top: 1rem;
|
||||
font-size: 0.875rem;
|
||||
}
|
||||
|
||||
.public-footer {
|
||||
padding-top: 1rem;
|
||||
border-top: 1px solid var(--line);
|
||||
color: var(--muted);
|
||||
font-size: 0.75rem;
|
||||
letter-spacing: 0.06em;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
|
||||
@media (max-width: 40rem) {
|
||||
.form-grid {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user