Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
92f852e335 | ||
|
|
cfb816b724 | ||
|
|
4e413fe600 | ||
|
|
68fd9dfc15 |
No files matched your search
@@ -158,7 +158,7 @@ jobs:
|
||||
mkdir -p "$RUNNER_TEMP/lunchdaten"
|
||||
echo "LUNCH_DATA=$RUNNER_TEMP/lunchdaten" >> "$GITHUB_ENV"
|
||||
# HOSTNAME: Next bindet sich daran; im Container ist es die Kennung des Containers.
|
||||
(cd .next/standalone && HOSTNAME=0.0.0.0 PORT=3020 BACKUP_DISABLED=1 IMPORT_TEST_ORIGIN=http://127.0.0.1:3021 APP_DATA_DIR="$RUNNER_TEMP/lunchdaten" \
|
||||
(cd .next/standalone && HOSTNAME=0.0.0.0 PORT=3020 BACKUP_DISABLED=1 IMPORT_TEST_ORIGIN=http://127.0.0.1:3021 APP_DATA_DIR="$RUNNER_TEMP/lunchdaten" MAIL_TEST_DIR="$RUNNER_TEMP/lunchdaten/mails" \
|
||||
nohup node server.js > "$RUNNER_TEMP/server.log" 2>&1 &)
|
||||
for i in $(seq 30); do curl -sf localhost:3020/api/ready && exit 0; sleep 1; done
|
||||
cat "$RUNNER_TEMP/server.log"; exit 1
|
||||
|
||||
@@ -0,0 +1,175 @@
|
||||
{
|
||||
"projekt": "lunch",
|
||||
"lauf": "2026-11-07",
|
||||
"auth_typ": "passkey+magic-link",
|
||||
"asvs_level": 2,
|
||||
"gesamturteil": "solide",
|
||||
"live_geprueft": true,
|
||||
"abdeckung": {
|
||||
"geprueft": 14,
|
||||
"erfuellt": 13,
|
||||
"verletzt": 0,
|
||||
"nicht_anwendbar": 0,
|
||||
"nicht_angestrebt": 1
|
||||
},
|
||||
"befunde": [
|
||||
{
|
||||
"id": "passkey-ohne-user-verification",
|
||||
"titel": "Passkey ohne Prüfung der Person",
|
||||
"schweregrad": "mittel",
|
||||
"asvs": [
|
||||
"6.5.x"
|
||||
],
|
||||
"datei": "lib/auth/webauthn.ts",
|
||||
"angriff": "Ein Schlüssel ohne PIN genügt.",
|
||||
"fix": "userVerification required, requireUserVerification true",
|
||||
"belegt_durch": "live",
|
||||
"status": "behoben"
|
||||
},
|
||||
{
|
||||
"id": "geraet-person-nicht-entfernbar",
|
||||
"titel": "Verlorenes Gerät und Personen nicht entfernbar",
|
||||
"schweregrad": "mittel",
|
||||
"asvs": [
|
||||
"7.4.x",
|
||||
"7.5.x"
|
||||
],
|
||||
"datei": "app/(app)/mehr/page.tsx",
|
||||
"angriff": "Verlorenes Handy bleibt 180 Tage angemeldet.",
|
||||
"fix": "Passkey und Person entfernen, Sitzungen hängen am Passkey",
|
||||
"belegt_durch": "live",
|
||||
"status": "behoben"
|
||||
},
|
||||
{
|
||||
"id": "kein-rueckweg-letzter-passkey",
|
||||
"titel": "Kein Rückweg bei Verlust des letzten Passkeys",
|
||||
"schweregrad": "mittel",
|
||||
"asvs": [
|
||||
"6.4.x"
|
||||
],
|
||||
"datei": "lib/auth/codes.ts",
|
||||
"angriff": "Haushalt verloren, wenn das einzige Gerät weg ist.",
|
||||
"fix": "Wiederherstellungscode in /app/data",
|
||||
"belegt_durch": "live",
|
||||
"status": "behoben"
|
||||
},
|
||||
{
|
||||
"id": "bremse-xff-umgehbar",
|
||||
"titel": "Bremse über X-Forwarded-For umgehbar",
|
||||
"schweregrad": "niedrig",
|
||||
"asvs": [
|
||||
"6.3.1"
|
||||
],
|
||||
"datei": "lib/auth/request.ts",
|
||||
"angriff": "Je Versuch neue vorgetäuschte Adresse.",
|
||||
"fix": "gemeinsamer Topf je Bremse",
|
||||
"belegt_durch": "live",
|
||||
"status": "behoben"
|
||||
},
|
||||
{
|
||||
"id": "kein-anmeldeprotokoll",
|
||||
"titel": "Anmeldungen werden nicht protokolliert",
|
||||
"schweregrad": "niedrig",
|
||||
"asvs": [
|
||||
"16.x"
|
||||
],
|
||||
"datei": "lib/auth/",
|
||||
"angriff": "Missbrauch bleibt unbemerkt.",
|
||||
"fix": "Protokolltabelle mit Arbeitspaket 2",
|
||||
"belegt_durch": "live",
|
||||
"status": "offen"
|
||||
},
|
||||
{
|
||||
"id": "sitzung-ohne-hoechstdauer",
|
||||
"titel": "Sitzung ohne absolute Höchstdauer",
|
||||
"schweregrad": "info",
|
||||
"asvs": [
|
||||
"7.3.2"
|
||||
],
|
||||
"datei": "lib/auth/session.ts",
|
||||
"angriff": "Gestohlener Keks bleibt gültig, solange benutzt.",
|
||||
"fix": "feste Obergrenze erwägen",
|
||||
"belegt_durch": "live",
|
||||
"status": "offen"
|
||||
},
|
||||
{
|
||||
"id": "keine-csp-hsts",
|
||||
"titel": "Keine CSP, HSTS ungeklärt",
|
||||
"schweregrad": "niedrig",
|
||||
"asvs": [
|
||||
"3.4.x"
|
||||
],
|
||||
"datei": "next.config.ts",
|
||||
"angriff": "Härtung gegen XSS und Downgrade fehlt.",
|
||||
"fix": "CSP mit Nonces, HSTS auf der Box prüfen",
|
||||
"belegt_durch": "live",
|
||||
"status": "offen"
|
||||
},
|
||||
{
|
||||
"id": "mail-versand-flutbar",
|
||||
"titel": "Mail-Kontingent und Postfach ließen sich fluten",
|
||||
"schweregrad": "niedrig",
|
||||
"asvs": [
|
||||
"6.3.1",
|
||||
"6.6.3"
|
||||
],
|
||||
"datei": "app/api/auth/mail/request/route.ts",
|
||||
"angriff": "Mit wechselnden IPs viele Links an eine bekannte Adresse, Resend-Kontingent verbraucht.",
|
||||
"fix": "Je Adresse 3/15 min und 10/Tag, gemeinsamer Topf 30/h",
|
||||
"belegt_durch": "code",
|
||||
"status": "behoben"
|
||||
},
|
||||
{
|
||||
"id": "mail-adresse-aufzaehlbar",
|
||||
"titel": "Vergebene Adressen ließen sich beim Eintragen erkennen",
|
||||
"schweregrad": "niedrig",
|
||||
"asvs": [
|
||||
"6.3.7"
|
||||
],
|
||||
"datei": "app/api/me/email/route.ts",
|
||||
"angriff": "Angemeldete Person prüft fremde Adressen auf Konten, auch haushaltsübergreifend.",
|
||||
"fix": "Gleiche Antwort; Link greift bei vergebener Adresse nicht",
|
||||
"belegt_durch": "code",
|
||||
"status": "behoben"
|
||||
},
|
||||
{
|
||||
"id": "mail-sitzung-ueberlebt-adresse",
|
||||
"titel": "Mail-Sitzungen überlebten das Entfernen der Adresse",
|
||||
"schweregrad": "niedrig",
|
||||
"asvs": [
|
||||
"7.4.x"
|
||||
],
|
||||
"datei": "app/api/me/email/route.ts",
|
||||
"angriff": "Wer das Postfach mitliest, bleibt angemeldet, obwohl die Adresse entfernt wurde.",
|
||||
"fix": "Adresse entfernen/ändern beendet Sitzungen via mail",
|
||||
"belegt_durch": "test",
|
||||
"status": "behoben"
|
||||
},
|
||||
{
|
||||
"id": "mail-sitzung-zu-lang",
|
||||
"titel": "Mail-Sitzungen lebten 180 Tage",
|
||||
"schweregrad": "niedrig",
|
||||
"asvs": [
|
||||
"7.3.x"
|
||||
],
|
||||
"datei": "lib/auth/session.ts",
|
||||
"angriff": "Ein einmal geöffneter Link hält ein halbes Jahr.",
|
||||
"fix": "30 Tage gleitend für via mail",
|
||||
"belegt_durch": "code",
|
||||
"status": "behoben"
|
||||
},
|
||||
{
|
||||
"id": "mail-link-nicht-geraetegebunden",
|
||||
"titel": "Mail-Link nicht an das anfragende Gerät gebunden",
|
||||
"schweregrad": "info",
|
||||
"asvs": [
|
||||
"6.6.2"
|
||||
],
|
||||
"datei": "lib/auth/mail-login.ts",
|
||||
"angriff": "Wer den Link hat, meldet sich an — auch auf einem anderen Gerät.",
|
||||
"fix": "Bewusst: Link soll auch auf anderem Gerät gehen; 15 min, einmal, nur Anmelden",
|
||||
"belegt_durch": "code",
|
||||
"status": "akzeptiert"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -7,7 +7,7 @@
|
||||
> **Plattform:** Olares One (Kubernetes), Repo und CI auf Gitea — kein Supabase,
|
||||
> kein Vercel (E-0001). Eigene Gestaltung, nicht AImighty (E-0002).
|
||||
> Verteilung über den Markt, Repo öffentlich (E-0005).
|
||||
> **Status:** 26.11.39 — alle neun Arbeitspakete aus `docs/PROJEKTSTART.md` sind gebaut:
|
||||
> **Status:** 26.11.43 — alle neun Arbeitspakete aus `docs/PROJEKTSTART.md` sind gebaut:
|
||||
> Anmeldung (Passkeys, Kinder mit Gerät + PIN), Gerichte (Link, Kochbuchfoto, AI über den
|
||||
> Olares Router), Wünschen, Plan, Einkaufsliste (Echtzeit, offline), Kochmodus mit
|
||||
> Bewertung, Web-App; Einzahl bei Stück-Mengen (26.11.15), Preise und Kosten mit Ampel
|
||||
@@ -19,8 +19,10 @@
|
||||
> lange Bons und Aldi (26.11.29), „Mein Gericht“ (26.11.30), Bons „nicht zum Kochen“
|
||||
> (26.11.33), foodplanhero für Maike (26.11.35), eine Schrift (26.11.37), Produktgruppen,
|
||||
> eigene Zutaten und Lieblingsprodukt je Haushalt (26.11.38, E-0015), Löffel und Gebinde
|
||||
> (26.11.39, E-0016). Offen ist der
|
||||
> Magic Link (braucht SMTP).
|
||||
> (26.11.39, E-0016), Anmelden per Mail-Link über Resend (26.11.40, E-0017; nur
|
||||
> anmelden, keine Geräte oder Passkeys aus einer Mail-Sitzung), Leiste bleibt nach der
|
||||
> Tastatur unten (26.11.41), Icon Kochmütze mit Herz (26.11.42), Fotos aus der Mediathek (26.11.43). Offen: Kai trägt
|
||||
> den Resend-Schlüssel unter Mehr › Mails verschicken ein.
|
||||
> **Letzte Aktualisierung:** 7. November 2026
|
||||
|
||||
Diese Datei ist das Gedächtnis jeder Sitzung. Entscheidungen stehen in
|
||||
|
||||
@@ -21,7 +21,7 @@ metadata:
|
||||
title: foodplanhero
|
||||
description: Plan. Cook. Smile. The family decides together what's for dinner — and the shopping list writes itself. Runs entirely on your own box.
|
||||
icon: https://git.aimighty.olares.de/aimighty/bilder/raw/branch/main/lunch/icon.png
|
||||
version: 26.11.39
|
||||
version: 26.11.43
|
||||
categories:
|
||||
- Applications
|
||||
|
||||
@@ -61,7 +61,7 @@ permission:
|
||||
appData: true
|
||||
|
||||
spec:
|
||||
versionName: '26.11.39'
|
||||
versionName: '26.11.43'
|
||||
|
||||
featuredImage: https://git.aimighty.olares.de/aimighty/bilder/raw/branch/main/lunch/icon.png
|
||||
promoteImage:
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { ChevronLeft, MonitorPlay } from "lucide-react";
|
||||
import { TrialNote } from "@/components/dishes/trial-note";
|
||||
import Link from "next/link";
|
||||
import { notFound } from "next/navigation";
|
||||
import { getLocale, getTranslations } from "next-intl/server";
|
||||
@@ -54,7 +55,7 @@ export default async function DishPage({ params }: { params: Promise<{ id: strin
|
||||
<div className="relative aspect-[4/3] overflow-hidden sm:mx-4 sm:mt-4 sm:rounded-2xl">
|
||||
<DishPhoto dishId={dish.id} photo={dish.photo} />
|
||||
<Link
|
||||
href="/gerichte"
|
||||
href={dish.isTrial ? "/gerichte?ansicht=ausprobieren" : "/gerichte"}
|
||||
aria-label={t("title")}
|
||||
className="absolute left-3 top-3 flex size-11 items-center justify-center rounded-full bg-background/90 text-foreground"
|
||||
>
|
||||
@@ -75,6 +76,7 @@ export default async function DishPage({ params }: { params: Promise<{ id: strin
|
||||
) : null}
|
||||
</header>
|
||||
{photos.length ? <PhotoGallery dishId={dish.id} title={dish.title} photos={photos} canManage={canWrite} /> : null}
|
||||
{dish.isTrial ? <TrialNote id={dish.id} canWrite={canWrite} /> : null}
|
||||
{canWrite ? <DishActions id={dish.id} /> : null}
|
||||
{dish.steps.length || dish.ingredients.length ? (
|
||||
<Link
|
||||
|
||||
@@ -107,7 +107,7 @@ export default async function DishesPage({ searchParams }: { searchParams: Promi
|
||||
href="/gerichte/hinzufuegen"
|
||||
className={cn(
|
||||
buttonVariants({ size: "lg" }),
|
||||
"fixed bottom-[calc(4.5rem+env(safe-area-inset-bottom))] right-4 z-10 shadow-lg",
|
||||
"kb-shift fixed bottom-[calc(4.5rem+env(safe-area-inset-bottom))] right-4 z-10 shadow-lg",
|
||||
)}
|
||||
>
|
||||
<Plus aria-hidden />
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
import { redirect } from "next/navigation";
|
||||
import { getTranslations } from "next-intl/server";
|
||||
import { MailSettings } from "@/components/more/mail-settings";
|
||||
import { requireSession } from "@/lib/auth/session";
|
||||
import { withHousehold } from "@/lib/db";
|
||||
import { loadMail, RESEND } from "@/lib/mail";
|
||||
|
||||
export const dynamic = "force-dynamic";
|
||||
|
||||
// Mails verschicken (26.11.40), nur für Admins; per Mail-Link angemeldet nur lesen.
|
||||
export default async function MailSettingsPage() {
|
||||
const session = await requireSession();
|
||||
if (session.role !== "admin") redirect("/mehr");
|
||||
const t = await getTranslations("more.mailSettings");
|
||||
const { stored, me } = await withHousehold(session.householdId, async (c) => ({
|
||||
stored: await loadMail(c),
|
||||
me: (await c.query("select email from members where id = $1", [session.memberId])).rows[0]?.email as string | null,
|
||||
}));
|
||||
return (
|
||||
<main className="mx-auto flex max-w-md flex-col gap-5 px-4 py-6">
|
||||
<header className="flex flex-col gap-1">
|
||||
<p className="eyebrow">{session.householdName}</p>
|
||||
<h1 className="text-4xl leading-tight">{t("title")}</h1>
|
||||
<p className="text-muted-foreground">{t("intro")}</p>
|
||||
</header>
|
||||
{session.via === "mail" ? (
|
||||
<p className="rounded-xl border border-border px-4 py-3 text-sm">{(await getTranslations("auth.errors"))("mailSession")}</p>
|
||||
) : (
|
||||
<MailSettings
|
||||
me={me}
|
||||
current={
|
||||
stored
|
||||
? { host: stored.host, port: stored.port, secure: stored.secure, username: stored.username, fromAddress: stored.fromAddress, fromName: stored.fromName, hasPassword: !!stored.passwordEnc }
|
||||
: null
|
||||
}
|
||||
defaults={{ ...RESEND, fromAddress: "hallo@foodplanhero.de", fromName: "foodplanhero", hasPassword: false }}
|
||||
/>
|
||||
)}
|
||||
</main>
|
||||
);
|
||||
}
|
||||
@@ -12,6 +12,8 @@ import { getDedication, photoVersion } from "@/lib/dedication";
|
||||
import { aiFor } from "@/lib/ai-settings";
|
||||
import { InstallHint } from "@/components/install-hint";
|
||||
import { BudgetSettings } from "@/components/more/budget-settings";
|
||||
import { MailSignIn } from "@/components/more/mail-sign-in";
|
||||
import { can, WITH_PASSKEY } from "@/lib/auth/roles";
|
||||
import { withHousehold } from "@/lib/db";
|
||||
import { isLocale } from "@/lib/locale";
|
||||
|
||||
@@ -30,7 +32,7 @@ export default async function MorePage() {
|
||||
const t = await getTranslations("more");
|
||||
const tc = await getTranslations("costs.settings");
|
||||
const locale = await getLocale();
|
||||
const { members, passkeys, founder, kids, kidDevices, money, dedication } = await withHousehold(session.householdId, async (client) => {
|
||||
const { members, passkeys, founder, kids, kidDevices, money, mail, dedication } = await withHousehold(session.householdId, async (client) => {
|
||||
const members = (await client.query("select id, display_name, role from members order by created_at")).rows;
|
||||
const founder = (await client.query("select created_by from households")).rows[0]?.created_by as string | null;
|
||||
const passkeys = (
|
||||
@@ -46,7 +48,17 @@ export default async function MorePage() {
|
||||
)
|
||||
).rows;
|
||||
const money = (await client.query("select budget_per_round::float as budget, expensive_per_slots as per, currency from households")).rows[0];
|
||||
return { members, passkeys, founder, kids, kidDevices, money, dedication: await getDedication(client) };
|
||||
// Anmelden per Mail (26.11.40): bestätigte Adresse, offene Bestätigung, eingerichteter Versand.
|
||||
const me = (await client.query("select email, email_verified_at is not null as verified from members where id = $1", [session.memberId])).rows[0];
|
||||
const pending = (
|
||||
await client.query(
|
||||
"select email from mail_tokens where member_id = $1 and purpose = 'verify' and used_at is null and expires_at > now() order by created_at desc limit 1",
|
||||
[session.memberId],
|
||||
)
|
||||
).rows[0]?.email as string | undefined;
|
||||
const sending = (await client.query("select from_address from household_mail where password_enc is not null")).rows[0]?.from_address as string | undefined;
|
||||
const mail = { verified: me?.verified ? (me.email as string) : null, pending: pending ?? null, sending: sending ?? null };
|
||||
return { members, passkeys, founder, kids, kidDevices, money, mail, dedication: await getDedication(client) };
|
||||
});
|
||||
const aiReady = !!(await aiFor(session.householdId));
|
||||
const date = new Intl.DateTimeFormat(locale, { dateStyle: "medium" });
|
||||
@@ -87,7 +99,7 @@ export default async function MorePage() {
|
||||
|
||||
{session.role === "admin" ? (
|
||||
<Section title={t("invitePerson")} id="einladen">
|
||||
<InvitePerson />
|
||||
{session.via === "mail" ? <p className="rounded-xl border border-border px-4 py-3 text-sm">{t("mail.locked")}</p> : <InvitePerson />}
|
||||
</Section>
|
||||
) : null}
|
||||
|
||||
@@ -105,9 +117,15 @@ export default async function MorePage() {
|
||||
</ul>
|
||||
{passkeys.length > 1 ? <p className="text-sm text-muted-foreground">{t("removeHint")}</p> : null}
|
||||
<h3 className="text-sm font-medium">{t("addDevice")}</h3>
|
||||
<AddDevice />
|
||||
{session.via === "mail" ? <p className="rounded-xl border border-border px-4 py-3 text-sm">{t("mail.locked")}</p> : <AddDevice />}
|
||||
</Section>
|
||||
|
||||
{can(WITH_PASSKEY, session.role) ? (
|
||||
<Section title={t("mail.title")} id="mail">
|
||||
<MailSignIn verified={mail.verified} pending={mail.pending} locked={session.via === "mail"} />
|
||||
</Section>
|
||||
) : null}
|
||||
|
||||
{session.role === "admin" ? (
|
||||
<>
|
||||
<Section title={t("kids.title")}>
|
||||
@@ -122,6 +140,21 @@ export default async function MorePage() {
|
||||
</>
|
||||
) : null}
|
||||
|
||||
{session.role === "admin" ? (
|
||||
<Section title={t("mail.sendingTitle")} id="mails">
|
||||
<Link
|
||||
href="/mehr/mail"
|
||||
className="flex min-h-11 items-center justify-between gap-2 rounded-2xl bg-muted px-4 py-3 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"
|
||||
>
|
||||
<span className="flex flex-col">
|
||||
<span>{mail.sending ? t("mail.sendingReady", { from: mail.sending }) : t("mail.sendingNotReady")}</span>
|
||||
<span className="text-sm text-muted-foreground">{t("mail.sendingSummary")}</span>
|
||||
</span>
|
||||
<ChevronRight aria-hidden className="size-5 text-muted-foreground" />
|
||||
</Link>
|
||||
</Section>
|
||||
) : null}
|
||||
|
||||
{session.role === "admin" ? (
|
||||
<Section title={t("ai.title")}>
|
||||
<Link
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
import { Slogan, Wordmark } from "@/components/brand/brand";
|
||||
import { MailLink } from "@/components/auth/mail-link";
|
||||
|
||||
export const dynamic = "force-dynamic";
|
||||
|
||||
// Ziel des Links aus der Mail (26.11.40). Wie AuthShell, nur dass Titel und Text
|
||||
// erst im Browser feststehen (der Token steht hinter #).
|
||||
export default function MailLinkPage() {
|
||||
return (
|
||||
<main className="mx-auto flex min-h-dvh w-full max-w-sm flex-col justify-center gap-6 px-4 py-10">
|
||||
<p className="flex flex-col items-center gap-2 text-center">
|
||||
<Wordmark className="text-4xl" />
|
||||
<Slogan />
|
||||
</p>
|
||||
<MailLink />
|
||||
</main>
|
||||
);
|
||||
}
|
||||
@@ -5,6 +5,7 @@ import { KIDS_COOKIE } from "@/lib/auth/kids";
|
||||
import { getTranslations } from "next-intl/server";
|
||||
import { AuthShell } from "@/components/auth/auth-shell";
|
||||
import { LoginButton } from "@/components/auth/login-button";
|
||||
import { MailLogin } from "@/components/auth/mail-login";
|
||||
import { getSession, isSetUp } from "@/lib/auth/session";
|
||||
import { photoVersion, publicDedication } from "@/lib/dedication";
|
||||
|
||||
@@ -19,6 +20,7 @@ export default async function SignInPage() {
|
||||
return (
|
||||
<AuthShell title={t("title")} intro={t("intro")} portrait={portrait}>
|
||||
<LoginButton />
|
||||
<MailLogin />
|
||||
{(await cookies()).has(KIDS_COOKIE) ? (
|
||||
<Link href="/kinder" className="mx-auto inline-flex min-h-11 items-center text-sm font-semibold underline-offset-4 hover:underline">
|
||||
{t("kids")}
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
import { z } from "zod";
|
||||
import { withAuth } from "@/lib/db";
|
||||
import { fail, json, readJson, sameOrigin } from "@/lib/auth/http";
|
||||
import { createMailToken, findMailMember, linkMail, normalizeEmail, sendInBackground } from "@/lib/auth/mail-login";
|
||||
import { clientIp } from "@/lib/auth/request";
|
||||
import { tooManyAttempts } from "@/lib/auth/throttle";
|
||||
import { loadInstance } from "@/lib/auth/webauthn";
|
||||
|
||||
export const dynamic = "force-dynamic";
|
||||
|
||||
const body = z.object({ email: z.string().trim().max(200).email() });
|
||||
|
||||
// Link per Mail anfordern (26.11.40). Die Antwort ist immer dieselbe — ob es die
|
||||
// Adresse gibt, verrät sie nicht, auch nicht durch ihre Dauer (Versand im Hintergrund).
|
||||
export async function POST(request: Request) {
|
||||
const parsed = body.safeParse(await readJson(request));
|
||||
const result = await withAuth(async (client) => {
|
||||
const instance = await loadInstance(client);
|
||||
if (!instance) return fail("notSetUp", 409);
|
||||
if (!sameOrigin(request, instance.origin)) return fail("origin", 403);
|
||||
if (!parsed.success) return fail("invalid", 400);
|
||||
const email = normalizeEmail(parsed.data.email);
|
||||
if (
|
||||
(await tooManyAttempts(client, `mail:${clientIp(request)}`, 10, 15)) ||
|
||||
(await tooManyAttempts(client, `mail-to:${email}`, 3, 15)) ||
|
||||
(await tooManyAttempts(client, `mail-to-day:${email}`, 10, 24 * 60)) ||
|
||||
// Gemeinsamer Topf: hält Resend-Kontingent und Absender-Ruf, auch wenn jemand Adressen variiert.
|
||||
(await tooManyAttempts(client, "mail:*", 30, 60))
|
||||
) {
|
||||
return fail("tooMany", 429);
|
||||
}
|
||||
const member = await findMailMember(client, email);
|
||||
if (!member) return null;
|
||||
const token = await createMailToken(client, { householdId: member.householdId, memberId: member.id, purpose: "login", email });
|
||||
return { member, token, email, origin: instance.origin };
|
||||
});
|
||||
if (result instanceof Response) return result;
|
||||
if (result) {
|
||||
sendInBackground(result.member.householdId, linkMail({ purpose: "login", to: result.email, token: result.token, origin: result.origin, locale: result.member.locale }));
|
||||
}
|
||||
return json({ ok: true });
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
import { z } from "zod";
|
||||
import { withAuth } from "@/lib/db";
|
||||
import { fail, isSecure, json, readJson, sameOrigin } from "@/lib/auth/http";
|
||||
import { consumeMailToken } from "@/lib/auth/mail-login";
|
||||
import { clientIp } from "@/lib/auth/request";
|
||||
import { startSession } from "@/lib/auth/session";
|
||||
import { tooManyAttempts } from "@/lib/auth/throttle";
|
||||
import { loadInstance } from "@/lib/auth/webauthn";
|
||||
|
||||
export const dynamic = "force-dynamic";
|
||||
|
||||
const body = z.object({ token: z.string().min(20).max(100) });
|
||||
|
||||
// Einen Link aus der Mail einlösen: „login“ beginnt eine Sitzung (via mail — nur
|
||||
// anmelden, E-0006), „verify“ bestätigt die eigene Adresse.
|
||||
export async function POST(request: Request) {
|
||||
const parsed = body.safeParse(await readJson(request));
|
||||
return withAuth(async (client) => {
|
||||
const instance = await loadInstance(client);
|
||||
if (!instance) return fail("notSetUp", 409);
|
||||
if (!sameOrigin(request, instance.origin)) return fail("origin", 403);
|
||||
if ((await tooManyAttempts(client, `mail-verify:${clientIp(request)}`, 20, 15)) || (await tooManyAttempts(client, "mail-verify:*", 200, 15))) {
|
||||
return fail("tooMany", 429);
|
||||
}
|
||||
if (!parsed.success) return fail("expired", 410);
|
||||
const hit = await consumeMailToken(client, parsed.data.token);
|
||||
if (!hit) return fail("expired", 410);
|
||||
if (hit.purpose === "login") {
|
||||
await startSession(client, { id: hit.memberId, householdId: hit.householdId, viaMail: true }, request, isSecure(instance.origin));
|
||||
}
|
||||
return json({ purpose: hit.purpose });
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
import { guardWrite, isResponse } from "@/lib/auth/guard";
|
||||
import { fail } from "@/lib/auth/http";
|
||||
import { withHousehold } from "@/lib/db";
|
||||
|
||||
export const dynamic = "force-dynamic";
|
||||
|
||||
// „In den Pool“ (26.11.41): ein Gericht aus „Ausprobieren“ zu den Stammgerichten.
|
||||
export async function POST(request: Request, { params }: { params: Promise<{ id: string }> }) {
|
||||
const { id } = await params;
|
||||
const session = await guardWrite(request);
|
||||
if (isResponse(session)) return session;
|
||||
if (!/^[0-9a-f-]{36}$/.test(id)) return fail("invalid", 400);
|
||||
const r = await withHousehold(session.householdId, (c) =>
|
||||
c.query("update dishes set is_trial = false, updated_at = now() where id = $1 and archived_at is null", [id]),
|
||||
);
|
||||
return r.rowCount === 1 ? new Response(null, { status: 204 }) : fail("notFound", 404);
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
import { can, WITH_PASSKEY } from "@/lib/auth/roles";
|
||||
import { noMailSession } from "@/lib/auth/guard";
|
||||
import { withAuth, withHousehold } from "@/lib/db";
|
||||
import { fail, json, readJson, sameOrigin } from "@/lib/auth/http";
|
||||
import { createInvitationBody } from "@/lib/auth/schemas";
|
||||
@@ -16,6 +17,8 @@ const DAYS = { person: 7, device: 1 } as const;
|
||||
export async function POST(request: Request) {
|
||||
const session = await getSession();
|
||||
if (!session) return fail("signedOut", 401);
|
||||
const mail = noMailSession(session);
|
||||
if (mail) return mail;
|
||||
const instance = await withAuth(loadInstance);
|
||||
if (!instance || !sameOrigin(request, instance.origin)) return fail("origin", 403);
|
||||
const body = createInvitationBody.safeParse(await readJson(request));
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { z } from "zod";
|
||||
import { guardWrite, isResponse } from "@/lib/auth/guard";
|
||||
import { guardWrite, noMailSession, isResponse } from "@/lib/auth/guard";
|
||||
import { fail, json, readJson } from "@/lib/auth/http";
|
||||
import { createKidDeviceLink, LINK_HOURS } from "@/lib/auth/kids";
|
||||
import { loadInstance } from "@/lib/auth/webauthn";
|
||||
@@ -11,6 +11,8 @@ export const dynamic = "force-dynamic";
|
||||
export async function POST(request: Request) {
|
||||
const session = await guardWrite(request, ["admin"]);
|
||||
if (isResponse(session)) return session;
|
||||
const mail = noMailSession(session);
|
||||
if (mail) return mail;
|
||||
const body = z.object({ label: z.string().trim().min(1).max(60), kind: z.enum(["kids", "kitchen"]).default("kids") }).safeParse(await readJson(request));
|
||||
if (!body.success) return fail("invalid", 400);
|
||||
const instance = (await withAuth(loadInstance))!;
|
||||
@@ -22,6 +24,8 @@ export async function POST(request: Request) {
|
||||
export async function DELETE(request: Request) {
|
||||
const session = await guardWrite(request, ["admin"]);
|
||||
if (isResponse(session)) return session;
|
||||
const mail = noMailSession(session);
|
||||
if (mail) return mail;
|
||||
const body = z.object({ id: z.string().uuid() }).safeParse(await readJson(request));
|
||||
if (!body.success) return fail("invalid", 400);
|
||||
const removed = await withHousehold(session.householdId, (c) => c.query("delete from kid_devices where id = $1", [body.data.id]));
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
import { z } from "zod";
|
||||
import { guardWrite, isResponse, noMailSession } from "@/lib/auth/guard";
|
||||
import { fail, json, readJson } from "@/lib/auth/http";
|
||||
import { withHousehold } from "@/lib/db";
|
||||
import { seal } from "@/lib/vault";
|
||||
|
||||
export const dynamic = "force-dynamic";
|
||||
|
||||
// Mailweg des Haushalts (26.11.40), nur für Admins. Das Passwort (bei Resend der
|
||||
// API-Schlüssel) geht nur hinein: verschlüsselt gespeichert, nie zurückgegeben.
|
||||
const input = z.object({
|
||||
host: z.string().trim().min(1).max(200).regex(/^[a-z0-9.-]+$/i),
|
||||
port: z.number().int().min(1).max(65535),
|
||||
secure: z.boolean(),
|
||||
username: z.string().trim().min(1).max(200),
|
||||
// undefined: bleibt; Text: neu; null: entfernen
|
||||
password: z.string().trim().min(1).max(500).nullable().optional(),
|
||||
fromAddress: z.string().trim().max(200).email(),
|
||||
fromName: z.string().trim().max(80).nullable().optional(),
|
||||
});
|
||||
|
||||
export async function PUT(request: Request) {
|
||||
const session = await guardWrite(request, ["admin"]);
|
||||
if (isResponse(session)) return session;
|
||||
const mail = noMailSession(session);
|
||||
if (mail) return mail;
|
||||
const body = input.safeParse(await readJson(request));
|
||||
if (!body.success) return fail("invalid", 400);
|
||||
const d = body.data;
|
||||
const sealed = d.password ? await seal(d.password) : null;
|
||||
await withHousehold(session.householdId, (c) =>
|
||||
c.query(
|
||||
`insert into household_mail (household_id, host, port, secure, username, password_enc, from_address, from_name, updated_by)
|
||||
values ($1, $2, $3, $4, $5, $6, $7, $8, $9)
|
||||
on conflict (household_id) do update set host = $2, port = $3, secure = $4, username = $5,
|
||||
password_enc = case when $10 then $6 else household_mail.password_enc end,
|
||||
from_address = $7, from_name = $8, updated_by = $9, updated_at = now()`,
|
||||
[session.householdId, d.host.toLowerCase(), d.port, d.secure, d.username, sealed, d.fromAddress.toLowerCase(), d.fromName || null, session.memberId, d.password !== undefined],
|
||||
),
|
||||
);
|
||||
return json({ ok: true });
|
||||
}
|
||||
|
||||
export async function DELETE(request: Request) {
|
||||
const session = await guardWrite(request, ["admin"]);
|
||||
if (isResponse(session)) return session;
|
||||
const mail = noMailSession(session);
|
||||
if (mail) return mail;
|
||||
await withHousehold(session.householdId, (c) => c.query("delete from household_mail"));
|
||||
return json({ ok: true });
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
import { z } from "zod";
|
||||
import { getTranslations } from "next-intl/server";
|
||||
import { guardWrite, isResponse, noMailSession } from "@/lib/auth/guard";
|
||||
import { fail, json, readJson } from "@/lib/auth/http";
|
||||
import { tooManyAttempts } from "@/lib/auth/throttle";
|
||||
import { loadInstance } from "@/lib/auth/webauthn";
|
||||
import { withAuth } from "@/lib/db";
|
||||
import { buttonMail, MailNotConfigured, sendMail } from "@/lib/mail";
|
||||
|
||||
export const dynamic = "force-dynamic";
|
||||
|
||||
const body = z.object({ to: z.string().trim().max(200).email() });
|
||||
|
||||
// „Testmail an mich“: prüft den Zugang mit einer echten Mail. Nur Admins, gebremst.
|
||||
export async function POST(request: Request) {
|
||||
const session = await guardWrite(request, ["admin"]);
|
||||
if (isResponse(session)) return session;
|
||||
const mail = noMailSession(session);
|
||||
if (mail) return mail;
|
||||
const parsed = body.safeParse(await readJson(request));
|
||||
if (!parsed.success) return fail("invalid", 400);
|
||||
const origin = await withAuth(async (client) => {
|
||||
if (await tooManyAttempts(client, `mail-test:${session.householdId}`, 5, 15)) return null;
|
||||
return (await loadInstance(client))!.origin;
|
||||
});
|
||||
if (!origin) return fail("tooMany", 429);
|
||||
const t = await getTranslations("mail.test");
|
||||
try {
|
||||
await sendMail(session.householdId, buttonMail({ to: parsed.data.to.toLowerCase(), subject: t("subject"), lead: t("lead"), button: t("button"), url: origin, note: t("note") }));
|
||||
} catch (error) {
|
||||
if (error instanceof MailNotConfigured) return fail("mailNotConfigured", 409);
|
||||
// Der Grund des Servers hilft beim Einrichten (falscher Schlüssel, Absender nicht bestätigt) — nur für Admins.
|
||||
return json({ error: "mailFailed", detail: String((error as Error).message).slice(0, 300) }, 502);
|
||||
}
|
||||
return json({ ok: true });
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
import { z } from "zod";
|
||||
import { noMailSession } from "@/lib/auth/guard";
|
||||
import { withAuth, withHousehold } from "@/lib/db";
|
||||
import { fail, readJson, sameOrigin } from "@/lib/auth/http";
|
||||
import { getSession } from "@/lib/auth/session";
|
||||
@@ -11,6 +12,8 @@ export const dynamic = "force-dynamic";
|
||||
export async function POST(request: Request) {
|
||||
const session = await getSession();
|
||||
if (!session) return fail("signedOut", 401);
|
||||
const mail = noMailSession(session);
|
||||
if (mail) return mail;
|
||||
const instance = await withAuth(loadInstance);
|
||||
if (!instance || !sameOrigin(request, instance.origin)) return fail("origin", 403);
|
||||
if (session.role !== "admin") return fail("forbidden", 403);
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
import { z } from "zod";
|
||||
import { guardWrite, isResponse, noMailSession } from "@/lib/auth/guard";
|
||||
import { fail, json, readJson } from "@/lib/auth/http";
|
||||
import { createMailToken, linkMail, normalizeEmail } from "@/lib/auth/mail-login";
|
||||
import { WITH_PASSKEY } from "@/lib/auth/roles";
|
||||
import { tooManyAttempts } from "@/lib/auth/throttle";
|
||||
import { loadInstance } from "@/lib/auth/webauthn";
|
||||
import { withAuth } from "@/lib/db";
|
||||
import { MailNotConfigured, sendMail } from "@/lib/mail";
|
||||
|
||||
export const dynamic = "force-dynamic";
|
||||
|
||||
const body = z.object({ email: z.string().trim().max(200).email() });
|
||||
|
||||
// Die eigene Adresse für den Mail-Link (26.11.40): eintragen schickt eine
|
||||
// Bestätigung; erst der Link darin schaltet die Anmeldung per Mail frei.
|
||||
export async function PUT(request: Request) {
|
||||
const session = await guardWrite(request, [...WITH_PASSKEY]);
|
||||
if (isResponse(session)) return session;
|
||||
const mail = noMailSession(session);
|
||||
if (mail) return mail;
|
||||
const parsed = body.safeParse(await readJson(request));
|
||||
if (!parsed.success) return fail("invalid", 400);
|
||||
const email = normalizeEmail(parsed.data.email);
|
||||
const prepared = await withAuth(async (client) => {
|
||||
if (await tooManyAttempts(client, `mail-confirm:${session.memberId}`, 5, 60)) return fail("tooMany", 429);
|
||||
// Ob die Adresse schon jemandem gehört, sagt diese Antwort nicht (auch nicht über Haushalte
|
||||
// hinweg): Die Mail geht raus, der Link darin greift dann nicht (consumeMailToken).
|
||||
const locale = (await client.query("select locale from members where id = $1", [session.memberId])).rows[0]?.locale ?? null;
|
||||
const token = await createMailToken(client, { householdId: session.householdId, memberId: session.memberId, purpose: "verify", email });
|
||||
return { token, locale, origin: (await loadInstance(client))!.origin };
|
||||
});
|
||||
if (prepared instanceof Response) return prepared;
|
||||
try {
|
||||
await sendMail(session.householdId, await linkMail({ purpose: "verify", to: email, ...prepared }));
|
||||
} catch (error) {
|
||||
return fail(error instanceof MailNotConfigured ? "mailNotConfigured" : "mailFailed", 502);
|
||||
}
|
||||
return json({ pending: email });
|
||||
}
|
||||
|
||||
export async function DELETE(request: Request) {
|
||||
const session = await guardWrite(request, [...WITH_PASSKEY]);
|
||||
if (isResponse(session)) return session;
|
||||
const mail = noMailSession(session);
|
||||
if (mail) return mail;
|
||||
await withAuth(async (client) => {
|
||||
await client.query("update members set email = null, email_verified_at = null where id = $1", [session.memberId]);
|
||||
await client.query("update mail_tokens set used_at = now() where member_id = $1 and used_at is null", [session.memberId]);
|
||||
// Wer die Adresse entfernt, beendet auch jede Sitzung, die über sie begann.
|
||||
await client.query("delete from sessions where member_id = $1 and via = 'mail'", [session.memberId]);
|
||||
});
|
||||
return json({ ok: true });
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
import { z } from "zod";
|
||||
import { noMailSession } from "@/lib/auth/guard";
|
||||
import { withAuth, withHousehold } from "@/lib/db";
|
||||
import { fail, readJson, sameOrigin } from "@/lib/auth/http";
|
||||
import { getSession } from "@/lib/auth/session";
|
||||
@@ -12,6 +13,8 @@ export const dynamic = "force-dynamic";
|
||||
export async function POST(request: Request) {
|
||||
const session = await getSession();
|
||||
if (!session) return fail("signedOut", 401);
|
||||
const mail = noMailSession(session);
|
||||
if (mail) return mail;
|
||||
const instance = await withAuth(loadInstance);
|
||||
if (!instance || !sameOrigin(request, instance.origin)) return fail("origin", 403);
|
||||
const body = z.object({ id: z.string().min(1).max(1024) }).safeParse(await readJson(request));
|
||||
|
||||
@@ -79,6 +79,12 @@
|
||||
--nav-space: 0px;
|
||||
}
|
||||
|
||||
/* Knopfleisten unten folgen der Korrektur der Navigation, wenn iOS nach der
|
||||
Tastatur zu kurz rechnet (lib/use-keyboard-nav.ts setzt --kb-shift, 26.11.41). */
|
||||
.kb-shift {
|
||||
translate: 0 var(--kb-shift, 0px);
|
||||
}
|
||||
|
||||
html {
|
||||
color-scheme: light dark;
|
||||
-webkit-text-size-adjust: 100%;
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { iconUrl } from "@/lib/icon-version";
|
||||
import type { Metadata, Viewport } from "next";
|
||||
import localFont from "next/font/local";
|
||||
import { NextIntlClientProvider } from "next-intl";
|
||||
@@ -36,7 +37,7 @@ export async function generateMetadata(): Promise<Metadata> {
|
||||
media: `(device-width: ${cw}px) and (device-height: ${ch}px) and (-webkit-device-pixel-ratio: ${dpr}) and (orientation: portrait)`,
|
||||
})),
|
||||
},
|
||||
icons: { icon: "/icon.svg", apple: "/apple-touch-icon.png" },
|
||||
icons: { icon: iconUrl("/icon.svg"), apple: iconUrl("/apple-touch-icon.png") },
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { iconUrl } from "@/lib/icon-version";
|
||||
import type { MetadataRoute } from "next";
|
||||
import { getLocale, getTranslations } from "next-intl/server";
|
||||
|
||||
@@ -18,14 +19,14 @@ export default async function manifest(): Promise<MetadataRoute.Manifest> {
|
||||
theme_color: "#fdfcfe",
|
||||
// Lange auf das Symbol drücken: direkt zu Wünschen, Plan und Einkauf.
|
||||
shortcuts: [
|
||||
{ name: nav("wish"), url: "/wuenschen", icons: [{ src: "/icon-192.png", sizes: "192x192" }] },
|
||||
{ name: nav("plan"), url: "/plan", icons: [{ src: "/icon-192.png", sizes: "192x192" }] },
|
||||
{ name: nav("shopping"), url: "/einkauf", icons: [{ src: "/icon-192.png", sizes: "192x192" }] },
|
||||
{ name: nav("wish"), url: "/wuenschen", icons: [{ src: iconUrl("/icon-192.png"), sizes: "192x192" }] },
|
||||
{ name: nav("plan"), url: "/plan", icons: [{ src: iconUrl("/icon-192.png"), sizes: "192x192" }] },
|
||||
{ name: nav("shopping"), url: "/einkauf", icons: [{ src: iconUrl("/icon-192.png"), sizes: "192x192" }] },
|
||||
],
|
||||
icons: [
|
||||
{ src: "/icon-192.png", sizes: "192x192", type: "image/png" },
|
||||
{ src: "/icon-512.png", sizes: "512x512", type: "image/png" },
|
||||
{ src: "/icon-512-maskable.png", sizes: "512x512", type: "image/png", purpose: "maskable" },
|
||||
{ src: iconUrl("/icon-192.png"), sizes: "192x192", type: "image/png" },
|
||||
{ src: iconUrl("/icon-512.png"), sizes: "512x512", type: "image/png" },
|
||||
{ src: iconUrl("/icon-512-maskable.png"), sizes: "512x512", type: "image/png", purpose: "maskable" },
|
||||
],
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
"use client";
|
||||
|
||||
import Link from "next/link";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { useTranslations } from "next-intl";
|
||||
import { useEffect, useState } from "react";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { ErrorNotice } from "@/components/ui/notice";
|
||||
|
||||
type State = { kind: "ready"; purpose: "login" | "verify"; token: string } | { kind: "expired" } | { kind: "verified" } | { kind: "loading" };
|
||||
|
||||
// Der Link aus der Mail (26.11.40): Der Token steht hinter # und geht nie an den
|
||||
// Server, bis die Person tippt — ein Mail-Scanner, der nur abruft, verbraucht ihn nicht.
|
||||
export function MailLink() {
|
||||
const t = useTranslations("auth");
|
||||
const router = useRouter();
|
||||
const [state, setState] = useState<State>({ kind: "loading" });
|
||||
const [busy, setBusy] = useState(false);
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
|
||||
useEffect(() => {
|
||||
const m = window.location.hash.match(/^#(login|verify)=([A-Za-z0-9_-]{20,100})$/);
|
||||
// Aus der Adresszeile nehmen: kein Token im Verlauf, kein zweites Einlösen beim Neuladen.
|
||||
history.replaceState(null, "", window.location.pathname);
|
||||
setState(m ? { kind: "ready", purpose: m[1] as "login" | "verify", token: m[2]! } : { kind: "expired" });
|
||||
}, []);
|
||||
|
||||
async function go() {
|
||||
if (state.kind !== "ready") return;
|
||||
setBusy(true);
|
||||
setError(null);
|
||||
const res = await fetch("/api/auth/mail/verify", {
|
||||
method: "POST",
|
||||
headers: { "content-type": "application/json" },
|
||||
body: JSON.stringify({ token: state.token }),
|
||||
}).catch(() => null);
|
||||
setBusy(false);
|
||||
if (res?.ok) {
|
||||
const { purpose } = await res.json();
|
||||
if (purpose === "login") router.replace("/");
|
||||
else setState({ kind: "verified" });
|
||||
return;
|
||||
}
|
||||
if (res?.status === 410) return setState({ kind: "expired" });
|
||||
setError(res?.status === 429 ? "tooMany" : "unknown");
|
||||
}
|
||||
|
||||
if (state.kind === "loading") return null;
|
||||
if (state.kind === "expired") {
|
||||
return (
|
||||
<div className="flex flex-col items-center gap-4 text-center">
|
||||
<h1 className="text-balance text-4xl leading-tight">{t("mailLink.expiredTitle")}</h1>
|
||||
<p className="mx-auto max-w-[34ch] text-balance text-muted-foreground">{t("mailLink.expiredIntro")}</p>
|
||||
<Button asChild size="lg" className="self-stretch">
|
||||
<Link href="/anmelden">{t("mailLink.back")}</Link>
|
||||
</Button>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
if (state.kind === "verified") {
|
||||
return (
|
||||
<div className="flex flex-col items-center gap-4 text-center">
|
||||
<h1 className="text-balance text-4xl leading-tight">{t("mailLink.verified")}</h1>
|
||||
<Button asChild size="lg" className="self-stretch">
|
||||
<Link href="/mehr">{t("mailLink.toMore")}</Link>
|
||||
</Button>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
const login = state.purpose === "login";
|
||||
return (
|
||||
<div className="flex flex-col items-center gap-4 text-center">
|
||||
<h1 className="text-balance text-4xl leading-tight">{t(login ? "mailLink.loginTitle" : "mailLink.verifyTitle")}</h1>
|
||||
<p className="mx-auto max-w-[34ch] text-balance text-muted-foreground">{t(login ? "mailLink.loginIntro" : "mailLink.verifyIntro")}</p>
|
||||
{error ? <ErrorNotice className="self-stretch">{t(`errors.${error}`)}</ErrorNotice> : null}
|
||||
<Button size="lg" className="self-stretch" onClick={go} disabled={busy}>
|
||||
{busy ? t("working") : t(login ? "mailLink.loginSubmit" : "mailLink.verifySubmit")}
|
||||
</Button>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
"use client";
|
||||
|
||||
import { Mail } from "lucide-react";
|
||||
import { useTranslations } from "next-intl";
|
||||
import { useId, useState } from "react";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { Label } from "@/components/ui/label";
|
||||
import { ErrorNotice } from "@/components/ui/notice";
|
||||
|
||||
// Link per Mail anfordern (26.11.40). Die Antwort sagt immer dasselbe — ob es die
|
||||
// Adresse gibt, verrät sie nicht.
|
||||
export function MailLogin() {
|
||||
const t = useTranslations("auth");
|
||||
const id = useId();
|
||||
const [open, setOpen] = useState(false);
|
||||
const [email, setEmail] = useState("");
|
||||
const [busy, setBusy] = useState(false);
|
||||
const [sent, setSent] = useState(false);
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
|
||||
async function submit(event: React.FormEvent) {
|
||||
event.preventDefault();
|
||||
setBusy(true);
|
||||
setError(null);
|
||||
const res = await fetch("/api/auth/mail/request", {
|
||||
method: "POST",
|
||||
headers: { "content-type": "application/json" },
|
||||
body: JSON.stringify({ email }),
|
||||
}).catch(() => null);
|
||||
setBusy(false);
|
||||
if (res?.ok) return setSent(true);
|
||||
const key = res ? ((await res.json().catch(() => ({}))).error as string | undefined) : undefined;
|
||||
setError(key === "tooMany" || key === "invalid" ? key : "unknown");
|
||||
}
|
||||
|
||||
if (!open) {
|
||||
return (
|
||||
<Button type="button" variant="outline" size="lg" onClick={() => setOpen(true)}>
|
||||
<Mail aria-hidden />
|
||||
{t("login.mailToggle")}
|
||||
</Button>
|
||||
);
|
||||
}
|
||||
if (sent) {
|
||||
return (
|
||||
<p role="status" className="mx-auto max-w-[34ch] text-balance rounded-xl border border-border px-4 py-3 text-center text-sm">
|
||||
{t("login.mailSent")}
|
||||
</p>
|
||||
);
|
||||
}
|
||||
return (
|
||||
<form onSubmit={submit} className="flex flex-col gap-3">
|
||||
<Label htmlFor={id}>{t("login.mailLabel")}</Label>
|
||||
<Input id={id} type="email" autoComplete="email" inputMode="email" required value={email} onChange={(e) => setEmail(e.target.value)} />
|
||||
{error ? <ErrorNotice>{t(`errors.${error}`)}</ErrorNotice> : null}
|
||||
<Button type="submit" size="lg" disabled={busy || !email.trim()}>
|
||||
<Mail aria-hidden />
|
||||
{busy ? t("working") : t("login.mailSubmit")}
|
||||
</Button>
|
||||
</form>
|
||||
);
|
||||
}
|
||||
@@ -158,7 +158,7 @@ export function CookingMode({
|
||||
|
||||
{error ? <ErrorNotice>{t("error")}</ErrorNotice> : null}
|
||||
|
||||
<div className="sticky bottom-[var(--nav-space)] z-10 flex gap-2 bg-background py-2">
|
||||
<div className="kb-shift sticky bottom-[var(--nav-space)] z-10 flex gap-2 bg-background py-2">
|
||||
<Button type="button" variant="outline" size="lg" disabled={index < 0} onClick={() => go(-1)} aria-label={t("back")}>
|
||||
<ChevronLeft aria-hidden />
|
||||
</Button>
|
||||
|
||||
@@ -85,7 +85,6 @@ export function RateCard({ item }: { item: ToRate }) {
|
||||
ref={file}
|
||||
type="file"
|
||||
accept="image/*"
|
||||
capture="environment"
|
||||
className="sr-only"
|
||||
tabIndex={-1}
|
||||
aria-hidden
|
||||
|
||||
@@ -24,19 +24,24 @@ export function PhotoButton({
|
||||
const [busy, setBusy] = useState(false);
|
||||
const [error, setError] = useState<"photo" | "full" | null>(null);
|
||||
|
||||
async function upload(file: File) {
|
||||
// Mehrere aus der Mediathek (26.11.43): nacheinander, bis fünf erreicht sind.
|
||||
async function upload(files: File[]) {
|
||||
setBusy(true);
|
||||
setError(null);
|
||||
const form = new FormData();
|
||||
form.append("photo", file);
|
||||
const res = await fetch(`/api/dishes/${id}/photos`, {
|
||||
method: "POST",
|
||||
body: form,
|
||||
});
|
||||
let failed: "photo" | "full" | null = null;
|
||||
for (const file of files.slice(0, Math.max(0, 5 - count))) {
|
||||
const form = new FormData();
|
||||
form.append("photo", file);
|
||||
const res = await fetch(`/api/dishes/${id}/photos`, { method: "POST", body: form }).catch(() => null);
|
||||
if (!res?.ok) {
|
||||
failed = res && (await res.json().catch(() => ({}))).error === "full" ? "full" : "photo";
|
||||
break;
|
||||
}
|
||||
}
|
||||
setBusy(false);
|
||||
if (input.current) input.current.value = "";
|
||||
if (res.ok) router.refresh();
|
||||
else setError((await res.json().catch(() => ({}))).error === "full" ? "full" : "photo");
|
||||
setError(failed);
|
||||
router.refresh();
|
||||
}
|
||||
|
||||
return (
|
||||
@@ -45,11 +50,12 @@ export function PhotoButton({
|
||||
ref={input}
|
||||
type="file"
|
||||
accept="image/*"
|
||||
capture="environment"
|
||||
// Ohne capture: Das iPhone bietet Fotomediathek, Kamera und Dateien an (Kai, 26.11.43).
|
||||
multiple
|
||||
className="sr-only"
|
||||
tabIndex={-1}
|
||||
aria-hidden
|
||||
onChange={(e) => e.target.files?.[0] && upload(e.target.files[0])}
|
||||
onChange={(e) => e.target.files?.length && upload(Array.from(e.target.files))}
|
||||
/>
|
||||
<Button
|
||||
variant="secondary"
|
||||
|
||||
@@ -491,7 +491,7 @@ export function DishForm({ initial }: { initial?: DishFormValue }) {
|
||||
</section>
|
||||
|
||||
{error ? <ErrorNotice>{t(`form.errors.${error}`)}</ErrorNotice> : null}
|
||||
<div className="sticky bottom-[var(--nav-space)] z-10 flex gap-2 bg-background py-2">
|
||||
<div className="kb-shift sticky bottom-[var(--nav-space)] z-10 flex gap-2 bg-background py-2">
|
||||
<Button type="button" variant="outline" onClick={() => router.back()}>
|
||||
{t("form.cancel")}
|
||||
</Button>
|
||||
|
||||
@@ -43,7 +43,6 @@ export function PhotoImport() {
|
||||
<input
|
||||
type="file"
|
||||
accept="image/*"
|
||||
capture="environment"
|
||||
multiple
|
||||
className="sr-only"
|
||||
aria-label={t("choose")}
|
||||
|
||||
@@ -61,7 +61,7 @@ export function StarterPicker({ starters }: { starters: Starter[] }) {
|
||||
})}
|
||||
</ul>
|
||||
{error ? <ErrorNotice>{t("form.errors.unknown")}</ErrorNotice> : null}
|
||||
<div className="sticky bottom-[var(--nav-space)] z-10 bg-background/0 pb-2">
|
||||
<div className="kb-shift sticky bottom-[var(--nav-space)] z-10 bg-background/0 pb-2">
|
||||
<Button
|
||||
size="lg"
|
||||
className="w-full shadow-lg"
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
"use client";
|
||||
|
||||
import Link from "next/link";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { useTranslations } from "next-intl";
|
||||
import { useState } from "react";
|
||||
import { Button } from "@/components/ui/button";
|
||||
|
||||
// Ein Gericht unter „Ausprobieren“ sagt das selbst (26.11.41, Kai: „neue Gerichte werden
|
||||
// nicht gespeichert“ — sie standen nur nicht im Pool). Mit einem Tipp in den Pool.
|
||||
export function TrialNote({ id, canWrite }: { id: string; canWrite: boolean }) {
|
||||
const t = useTranslations("dishes.detail");
|
||||
const router = useRouter();
|
||||
const [busy, setBusy] = useState(false);
|
||||
|
||||
async function toPool() {
|
||||
setBusy(true);
|
||||
const res = await fetch(`/api/dishes/${id}/pool`, { method: "POST" }).catch(() => null);
|
||||
setBusy(false);
|
||||
if (res?.ok) router.refresh();
|
||||
}
|
||||
|
||||
return (
|
||||
<div role="note" className="flex flex-col gap-3 rounded-xl border border-border px-4 py-3">
|
||||
<p className="text-sm">
|
||||
{t("inTrial")}{" "}
|
||||
<Link href="/gerichte?ansicht=ausprobieren" className="font-semibold underline underline-offset-4">
|
||||
{t("inTrialLink")}
|
||||
</Link>
|
||||
</p>
|
||||
{canWrite ? (
|
||||
<Button type="button" variant="outline" className="self-start" disabled={busy} onClick={toPool}>
|
||||
{t("toPool")}
|
||||
</Button>
|
||||
) : null}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,155 @@
|
||||
"use client";
|
||||
|
||||
import { useRouter } from "next/navigation";
|
||||
import { useTranslations } from "next-intl";
|
||||
import { useState } from "react";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { Label } from "@/components/ui/label";
|
||||
import { ErrorNotice } from "@/components/ui/notice";
|
||||
|
||||
export type MailCurrent = {
|
||||
host: string;
|
||||
port: number;
|
||||
secure: boolean;
|
||||
username: string;
|
||||
fromAddress: string;
|
||||
fromName: string | null;
|
||||
hasPassword: boolean;
|
||||
} | null;
|
||||
|
||||
// Mails verschicken (nur Admin, 26.11.40). Voreinstellung Resend; der Schlüssel
|
||||
// geht nur hinein und wird nie angezeigt.
|
||||
export function MailSettings({ current, defaults, me }: { current: MailCurrent; defaults: NonNullable<MailCurrent>; me: string | null }) {
|
||||
const t = useTranslations("more.mailSettings");
|
||||
const te = useTranslations("auth.errors");
|
||||
const router = useRouter();
|
||||
const start = current ?? defaults;
|
||||
const [host, setHost] = useState(start.host);
|
||||
const [port, setPort] = useState(String(start.port));
|
||||
const [secure, setSecure] = useState(start.secure);
|
||||
const [username, setUsername] = useState(start.username);
|
||||
const [password, setPassword] = useState("");
|
||||
const [fromAddress, setFromAddress] = useState(start.fromAddress);
|
||||
const [fromName, setFromName] = useState(start.fromName ?? "");
|
||||
const [testTo, setTestTo] = useState(me ?? "");
|
||||
const [busy, setBusy] = useState(false);
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
const [note, setNote] = useState<string | null>(null);
|
||||
|
||||
async function save(event: React.FormEvent) {
|
||||
event.preventDefault();
|
||||
setBusy(true);
|
||||
setError(null);
|
||||
setNote(null);
|
||||
const res = await fetch("/api/household/mail", {
|
||||
method: "PUT",
|
||||
headers: { "content-type": "application/json" },
|
||||
body: JSON.stringify({
|
||||
host: host.trim(),
|
||||
port: Number(port),
|
||||
secure,
|
||||
username: username.trim(),
|
||||
password: password.trim() ? password.trim() : undefined,
|
||||
fromAddress: fromAddress.trim(),
|
||||
fromName: fromName.trim() || null,
|
||||
}),
|
||||
}).catch(() => null);
|
||||
setBusy(false);
|
||||
if (!res?.ok) return setError(te("invalid"));
|
||||
setPassword("");
|
||||
setNote(t("saved"));
|
||||
router.refresh();
|
||||
}
|
||||
|
||||
async function test() {
|
||||
setBusy(true);
|
||||
setError(null);
|
||||
setNote(null);
|
||||
const res = await fetch("/api/household/mail/test", { method: "POST", headers: { "content-type": "application/json" }, body: JSON.stringify({ to: testTo }) }).catch(() => null);
|
||||
setBusy(false);
|
||||
if (res?.ok) return setNote(t("testSent"));
|
||||
const data = res ? await res.json().catch(() => ({})) : {};
|
||||
if (data.error === "mailFailed") return setError(t("testFailed", { detail: data.detail ?? "" }));
|
||||
setError(te(["mailNotConfigured", "tooMany", "invalid"].includes(data.error) ? data.error : "unknown"));
|
||||
}
|
||||
|
||||
async function remove() {
|
||||
setBusy(true);
|
||||
await fetch("/api/household/mail", { method: "DELETE" }).catch(() => null);
|
||||
setBusy(false);
|
||||
router.refresh();
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="flex flex-col gap-5">
|
||||
<form onSubmit={save} className="flex flex-col gap-3">
|
||||
<div className="flex flex-col gap-1">
|
||||
<Label htmlFor="mail-host">{t("host")}</Label>
|
||||
<Input id="mail-host" value={host} onChange={(e) => setHost(e.target.value)} autoComplete="off" />
|
||||
</div>
|
||||
<div className="flex flex-col gap-1">
|
||||
<Label htmlFor="mail-port">{t("port")}</Label>
|
||||
<Input id="mail-port" inputMode="numeric" value={port} onChange={(e) => setPort(e.target.value)} />
|
||||
</div>
|
||||
<label className="flex min-h-11 items-center gap-3 text-sm">
|
||||
<input type="checkbox" checked={secure} onChange={(e) => setSecure(e.target.checked)} className="size-5 accent-primary" />
|
||||
{t("secure")}
|
||||
</label>
|
||||
<div className="flex flex-col gap-1">
|
||||
<Label htmlFor="mail-user">{t("username")}</Label>
|
||||
<Input id="mail-user" value={username} onChange={(e) => setUsername(e.target.value)} autoComplete="off" />
|
||||
</div>
|
||||
<div className="flex flex-col gap-1">
|
||||
<Label htmlFor="mail-password">{t("password")}</Label>
|
||||
<Input id="mail-password" type="password" value={password} onChange={(e) => setPassword(e.target.value)} autoComplete="new-password" placeholder="re_…" />
|
||||
{current?.hasPassword ? <p className="text-sm text-muted-foreground">{t("passwordSaved")}</p> : null}
|
||||
</div>
|
||||
<div className="flex flex-col gap-1">
|
||||
<Label htmlFor="mail-from">{t("fromAddress")}</Label>
|
||||
<Input id="mail-from" type="email" value={fromAddress} onChange={(e) => setFromAddress(e.target.value)} />
|
||||
</div>
|
||||
<div className="flex flex-col gap-1">
|
||||
<Label htmlFor="mail-from-name">{t("fromName")}</Label>
|
||||
<Input id="mail-from-name" value={fromName} onChange={(e) => setFromName(e.target.value)} maxLength={80} />
|
||||
</div>
|
||||
<Button type="submit" disabled={busy || (!current?.hasPassword && !password.trim())}>
|
||||
{t("save")}
|
||||
</Button>
|
||||
</form>
|
||||
|
||||
{current?.hasPassword ? (
|
||||
<div className="flex flex-col gap-2 border-t border-border pt-4">
|
||||
<Label htmlFor="mail-test-to">{t("testTo")}</Label>
|
||||
<Input id="mail-test-to" type="email" value={testTo} onChange={(e) => setTestTo(e.target.value)} />
|
||||
<Button type="button" variant="outline" disabled={busy || !testTo.trim()} onClick={test}>
|
||||
{t("test")}
|
||||
</Button>
|
||||
</div>
|
||||
) : null}
|
||||
|
||||
{error ? <ErrorNotice>{error}</ErrorNotice> : null}
|
||||
{note ? (
|
||||
<p role="status" className="rounded-xl border border-border px-4 py-3 text-sm">
|
||||
{note}
|
||||
</p>
|
||||
) : null}
|
||||
|
||||
<section className="flex flex-col gap-2 border-t border-border pt-4">
|
||||
<h2 className="eyebrow">{t("stepsTitle")}</h2>
|
||||
<ol className="flex list-decimal flex-col gap-1 pl-5 text-sm text-muted-foreground">
|
||||
<li>{t("step1")}</li>
|
||||
<li>{t("step2")}</li>
|
||||
<li>{t("step3")}</li>
|
||||
<li>{t("step4")}</li>
|
||||
</ol>
|
||||
</section>
|
||||
|
||||
{current ? (
|
||||
<Button type="button" variant="ghost" className="self-start" disabled={busy} onClick={remove}>
|
||||
{t("remove")}
|
||||
</Button>
|
||||
) : null}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
"use client";
|
||||
|
||||
import { useRouter } from "next/navigation";
|
||||
import { useTranslations } from "next-intl";
|
||||
import { useId, useState } from "react";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { Label } from "@/components/ui/label";
|
||||
import { ErrorNotice } from "@/components/ui/notice";
|
||||
|
||||
// Mehr › Anmelden per Mail (26.11.40): eigene Adresse eintragen, über den Link
|
||||
// bestätigen. Wer per Mail-Link angemeldet ist, ändert hier nichts (E-0006).
|
||||
export function MailSignIn({ verified, pending, locked }: { verified: string | null; pending: string | null; locked: boolean }) {
|
||||
const t = useTranslations("more.mail");
|
||||
const te = useTranslations("auth.errors");
|
||||
const router = useRouter();
|
||||
const id = useId();
|
||||
const [email, setEmail] = useState("");
|
||||
const [busy, setBusy] = useState(false);
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
const [sentTo, setSentTo] = useState<string | null>(pending);
|
||||
|
||||
async function save(event: React.FormEvent) {
|
||||
event.preventDefault();
|
||||
setBusy(true);
|
||||
setError(null);
|
||||
const res = await fetch("/api/me/email", { method: "PUT", headers: { "content-type": "application/json" }, body: JSON.stringify({ email }) }).catch(() => null);
|
||||
setBusy(false);
|
||||
if (res?.ok) {
|
||||
setSentTo((await res.json()).pending);
|
||||
setEmail("");
|
||||
return;
|
||||
}
|
||||
const key = res ? ((await res.json().catch(() => ({}))).error as string | undefined) : undefined;
|
||||
setError(key && ["mailNotConfigured", "mailFailed", "tooMany", "mailSession"].includes(key) ? key : "unknown");
|
||||
}
|
||||
|
||||
async function remove() {
|
||||
setBusy(true);
|
||||
await fetch("/api/me/email", { method: "DELETE" }).catch(() => null);
|
||||
setBusy(false);
|
||||
setSentTo(null);
|
||||
router.refresh();
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="flex flex-col gap-3">
|
||||
<p className="text-sm text-muted-foreground">{t("intro")}</p>
|
||||
{verified ? <p className="font-medium">{t("verified", { email: verified })}</p> : null}
|
||||
{sentTo && sentTo !== verified ? (
|
||||
<p role="status" className="rounded-xl border border-border px-4 py-3 text-sm">
|
||||
{t("pending", { email: sentTo })}
|
||||
</p>
|
||||
) : null}
|
||||
{locked ? (
|
||||
<p className="rounded-xl border border-border px-4 py-3 text-sm">{t("locked")}</p>
|
||||
) : (
|
||||
<>
|
||||
<form onSubmit={save} className="flex flex-col gap-2">
|
||||
<Label htmlFor={id}>{t("label")}</Label>
|
||||
<Input id={id} type="email" autoComplete="email" inputMode="email" required value={email} onChange={(e) => setEmail(e.target.value)} />
|
||||
{error ? <ErrorNotice>{te(error)}</ErrorNotice> : null}
|
||||
<Button type="submit" disabled={busy || !email.trim()}>
|
||||
{t("save")}
|
||||
</Button>
|
||||
</form>
|
||||
{verified || sentTo ? (
|
||||
<Button type="button" variant="ghost" className="self-start" disabled={busy} onClick={remove}>
|
||||
{t("remove")}
|
||||
</Button>
|
||||
) : null}
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -186,7 +186,7 @@ export function PlanBoard({
|
||||
) : null}
|
||||
|
||||
{status === "open" && slots.length ? (
|
||||
<div className="sticky bottom-[var(--nav-space)] z-10 bg-background py-2">
|
||||
<div className="kb-shift sticky bottom-[var(--nav-space)] z-10 bg-background py-2">
|
||||
<Button type="button" size="lg" className="w-full" disabled={busy} onClick={() => act("POST", "/api/plan/approve")}>
|
||||
{t("approve")}
|
||||
</Button>
|
||||
|
||||
@@ -281,7 +281,7 @@ export function ReceiptReview({ receipt }: { receipt: Receipt }) {
|
||||
{done ? (
|
||||
<p className="text-sm text-muted-foreground">{t("doneText")}</p>
|
||||
) : (
|
||||
<div className="sticky bottom-[var(--nav-space)] z-10 flex gap-2 bg-background py-2">
|
||||
<div className="kb-shift sticky bottom-[var(--nav-space)] z-10 flex gap-2 bg-background py-2">
|
||||
<Button type="button" variant="outline" disabled={busy} onClick={remove} aria-label={t("delete")}>
|
||||
<Trash2 aria-hidden />
|
||||
</Button>
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
-- Anmelden per Link aus der Mail (Kai, 7.11.2026, 26.11.40; E-0006, E-0017).
|
||||
--
|
||||
-- Mailweg je Haushalt (Resend über SMTP): Das Passwort (API-Schlüssel) liegt
|
||||
-- nur verschlüsselt hier (lib/vault.ts, tresor.key), wie bei household_ai.
|
||||
--
|
||||
-- Wer sich per Mail anmelden will, trägt seine Adresse selbst ein und bestätigt
|
||||
-- sie über einen ersten Link (email_verified_at). Ohne Bestätigung keine Mail.
|
||||
--
|
||||
-- mail_tokens: Einmal-Links zum Anmelden (15 Minuten) und zum Bestätigen
|
||||
-- (24 Stunden); gespeichert nur der Hash. Eine Sitzung merkt sich, womit sie
|
||||
-- begann (via): Wer per Mail kam, darf nur anmelden — keine Geräte, keine
|
||||
-- Passkeys, keine Einladungen (E-0006).
|
||||
|
||||
create table household_mail (
|
||||
household_id uuid primary key references households (id) on delete cascade,
|
||||
host text not null check (length(host) between 1 and 200),
|
||||
port integer not null check (port between 1 and 65535),
|
||||
secure boolean not null default true,
|
||||
username text not null check (length(username) between 1 and 200),
|
||||
password_enc bytea,
|
||||
from_address text not null check (from_address = lower(from_address) and from_address like '%@%'),
|
||||
from_name text check (length(from_name) <= 80),
|
||||
updated_by uuid references members (id) on delete set null,
|
||||
updated_at timestamptz not null default now()
|
||||
);
|
||||
alter table household_mail enable row level security;
|
||||
alter table household_mail force row level security;
|
||||
create policy household_mail_household on household_mail
|
||||
using (household_id = app_household_id())
|
||||
with check (household_id = app_household_id());
|
||||
|
||||
alter table members add column email_verified_at timestamptz;
|
||||
|
||||
create table mail_tokens (
|
||||
id uuid primary key default gen_random_uuid(),
|
||||
household_id uuid not null references households (id) on delete cascade,
|
||||
member_id uuid not null references members (id) on delete cascade,
|
||||
purpose text not null check (purpose in ('login', 'verify')),
|
||||
email text not null check (email = lower(email)),
|
||||
token_hash bytea not null unique,
|
||||
created_at timestamptz not null default now(),
|
||||
expires_at timestamptz not null,
|
||||
used_at timestamptz
|
||||
);
|
||||
create index mail_tokens_member_idx on mail_tokens (member_id);
|
||||
alter table mail_tokens enable row level security;
|
||||
alter table mail_tokens force row level security;
|
||||
-- Wie invitations: im Haushalt und für die Anmeldung, die den Haushalt erst findet.
|
||||
create policy mail_tokens_household on mail_tokens
|
||||
using (household_id = app_household_id() or app_auth())
|
||||
with check (household_id = app_household_id() or app_auth());
|
||||
|
||||
alter table sessions add column via text not null default 'passkey' check (via in ('passkey', 'mail', 'kid'));
|
||||
update sessions set via = 'kid' where kid_device_id is not null;
|
||||
@@ -177,7 +177,7 @@ acht Paletten Variante H gewählt). Löst die Palette aus E-0002 ab; der Rest vo
|
||||
- **Schrift:** ~~Überschriften in Newsreader, Text in Geist~~ — seit 26.11.37 Poppins
|
||||
überall (E-0014).
|
||||
- **Abschnitte** ohne Kasten, getrennt durch feine Linien.
|
||||
- **Symbol:** Teller mit Dampf auf Coral, Blatt in Lavendel (`docs/icon/lunch.svg`).
|
||||
- **Symbol:** Kochmütze mit Herz auf Coral (seit 26.11.42, Kai: Entwurf a; vorher Teller mit Dampf und Lavendel-Blatt), `docs/icon/lunch.svg`.
|
||||
- **Kontrast** jeder Schrift auf ihrer Fläche mindestens 4,5:1, hell und dunkel —
|
||||
`tests/contrast.test.ts` rechnet ihn aus den Token.
|
||||
|
||||
@@ -301,3 +301,37 @@ Preise rechnen also unverändert.
|
||||
des Haushalts, dann die Haushaltsgröße (`household_pack_sizes`, ändern darf, wer Gerichte
|
||||
pflegt), zuletzt die Vorgabe. Beim Einlesen von Rezepten kommt die Größe aus der Zutat,
|
||||
nie aus dem Text oder einem Modell.
|
||||
|
||||
## E-0017 · Mail-Link über Resend: nur anmelden
|
||||
|
||||
*7.11.2026 · Kai („Dann lieber resend“). Folgt E-0006.*
|
||||
|
||||
**Mailweg:** Resend über SMTP, Server `smtp.resend.com`, Port 465 mit TLS von
|
||||
Anfang an, Benutzer `resend`, Passwort ist ein API-Schlüssel. Der Absender ist
|
||||
`hallo@foodplanhero.de`.
|
||||
- Je Haushalt in `household_mail`. Der Schlüssel liegt nur verschlüsselt dort
|
||||
(`lib/vault.ts`) und kommt mit `tresor.key` in die Sicherung.
|
||||
- Die Felder bleiben änderbar, falls Resend etwas ändert.
|
||||
- Cloudflare Email Sending wäre möglich gewesen, braucht aber den bezahlten
|
||||
Workers-Tarif. Brevo war für die Domain schon vorbereitet. Kai hat Resend
|
||||
gewählt.
|
||||
|
||||
**Wer:** Nur wer es selbst einschaltet. Die Person trägt ihre Adresse unter Mehr
|
||||
ein und bestätigt sie über einen ersten Link (24 Stunden). Erwachsene und
|
||||
Jugendliche dürfen das, Kinder und Gäste nicht.
|
||||
|
||||
**Der Link:** Er gilt 15 Minuten und einmal; gespeichert ist nur der Hash.
|
||||
- Er steht hinter `#` auf `/anmelden/mail`. Eingelöst wird er erst per POST nach
|
||||
einem Tipp, so verbrauchen Mail-Scanner ihn nicht.
|
||||
- Die Antwort auf eine Anfrage ist immer gleich; der Versand läuft im Hintergrund.
|
||||
|
||||
**Nur anmelden** (Kai): Eine Sitzung mit `via = 'mail'` darf Folgendes nicht:
|
||||
- Passkeys oder Geräte hinzufügen oder entfernen
|
||||
- Einladungen und Kindergeräte erstellen
|
||||
- Personen entfernen
|
||||
- Adresse oder Mailweg ändern
|
||||
|
||||
Das prüft `noMailSession` in `lib/auth/guard.ts`. Mail-Sitzungen gelten 30 Tage
|
||||
statt 180. Adresse entfernen oder ändern beendet sie.
|
||||
|
||||
Sicherheitsprüfung: `docs/sicherheit/login-2026-11-07.md`.
|
||||
@@ -1,15 +1,8 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512">
|
||||
<rect width="512" height="512" rx="112" fill="#f39380"/>
|
||||
<!-- Teller -->
|
||||
<circle cx="256" cy="292" r="142" fill="#fefdff"/>
|
||||
<circle cx="256" cy="292" r="98" fill="none" stroke="#e7e1f6" stroke-width="14"/>
|
||||
<!-- Dampf -->
|
||||
<g fill="none" stroke="#fefdff" stroke-width="18" stroke-linecap="round">
|
||||
<path d="M206 78c-16 18 16 30 0 48"/>
|
||||
<path d="M256 64c-16 20 16 34 0 54"/>
|
||||
<path d="M306 78c-16 18 16 30 0 48"/>
|
||||
</g>
|
||||
<!-- Salbeiblatt -->
|
||||
<path d="M206 316c20-62 86-82 116-72-6 52-58 98-116 72z" fill="#7761b0"/>
|
||||
<path d="M214 312c30-24 58-42 96-62" stroke="#fefdff" stroke-width="7" stroke-linecap="round" fill="none"/>
|
||||
</svg>
|
||||
<!-- foodplanhero (Kai, 7.11.2026, 26.11.42): Kochmütze mit Herz, für Maike. Koralle wie bisher. --><rect width="512" height="512" rx="112" fill="#f39380"/><g>
|
||||
<circle cx="178" cy="214" r="70" fill="#fefdff"/>
|
||||
<circle cx="256" cy="176" r="86" fill="#fefdff"/>
|
||||
<circle cx="334" cy="214" r="70" fill="#fefdff"/>
|
||||
<rect x="158" y="210" width="196" height="132" fill="#fefdff"/>
|
||||
<rect x="150" y="350" width="212" height="56" rx="20" fill="#fefdff"/>
|
||||
</g><path d="M256 318 C230 298 202 276 202 250 C202 230 217 218 234 218 C245 218 252 224 256 233 C260 224 267 218 278 218 C295 218 310 230 310 250 C310 276 282 298 256 318 Z" fill="#f39380"/></svg>
|
||||
|
Before Width: | Height: | Size: 719 B After Width: | Height: | Size: 720 B |
@@ -0,0 +1,148 @@
|
||||
# Login-Sicherheit: Lunch (foodplanhero) — Mail-Link
|
||||
|
||||
**Gesamturteil:** 🟢 solide. Der neue Weg „Anmelden per Mail“ hat nach den
|
||||
Korrekturen in diesem PR keine offenen Befunde über „niedrig“.
|
||||
|
||||
**Geprüft am 7.11.2026, vor der Auslieferung von 26.11.40.**
|
||||
- **Auth-Typ:** Passkeys bleiben der Hauptweg. Neu ist ein **Mail-Link als
|
||||
zweiter Weg zum Anmelden**, nur für Personen, die ihre Adresse selbst
|
||||
eingetragen und bestätigt haben.
|
||||
- **Versand:** Resend über SMTP. Der Schlüssel liegt verschlüsselt im Tresor.
|
||||
- **ASVS-Ziel:** L2 (personenbezogene Daten, Kinder).
|
||||
- **Live geprüft** gegen localhost mit dem Mail-Ordner statt echtem Versand
|
||||
(`MAIL_TEST_DIR`, `e2e/mail.spec.ts`):
|
||||
- einrichten und Testmail schicken
|
||||
- Adresse bestätigen
|
||||
- unbekannte Adresse anfragen
|
||||
- per Link anmelden
|
||||
- Rechte der Mail-Sitzung
|
||||
- denselben Link ein zweites Mal öffnen
|
||||
- **Ohne echten Versand:** Gegen Resend wurde nichts geschickt; jeder Versuch
|
||||
kostet Kontingent.
|
||||
- **Geprüfte Dateien:**
|
||||
- `lib/auth/mail-login.ts`
|
||||
- `lib/mail.ts`
|
||||
- `app/api/auth/mail/{request,verify}`
|
||||
- `app/api/me/email`
|
||||
- `app/api/household/mail{,/test}`
|
||||
- `components/auth/mail-link.tsx`
|
||||
- `lib/auth/guard.ts` (`noMailSession`)
|
||||
- `lib/auth/session.ts` (`via`)
|
||||
- `db/migrations/0024_mail_sign_in.sql`
|
||||
|
||||
**Grundannahme, ausgesprochen.** Wer das Postfach hat, kommt in Lunch hinein. Das
|
||||
gilt nur für Personen, die die Anmeldung per Mail selbst einschalten.
|
||||
|
||||
Der Link öffnet nur die Anmeldung. Er schafft keinen Zugang über das hinaus, was
|
||||
eine Sitzung ohnehin kann (Kai, E-0006/E-0017). Aus einer Mail-Sitzung geht
|
||||
Folgendes nicht:
|
||||
- Passkeys oder Geräte hinzufügen oder entfernen
|
||||
- Einladungen und Kindergeräte erstellen
|
||||
- Personen entfernen
|
||||
- die eigene Adresse oder den Mailweg ändern
|
||||
|
||||
Wer sein Postfach verliert, verliert also nicht dauerhaft das Konto. Ein Angreifer
|
||||
mit dem Postfach hat höchstens 30 Tage Zugriff und kann keinen bleibenden
|
||||
Zugang anlegen.
|
||||
|
||||
**Vertrauensgrenzen.**
|
||||
1. **Der Token läuft nur im Browser.** Er steht hinter `#`, geht also nie in
|
||||
Server-Logs, Proxy-Logs oder den `Referer`. Der Server sieht ihn erst im
|
||||
POST nach einem Tipp, und dieser POST muss vom eigenen Ursprung kommen
|
||||
(`sameOrigin`).
|
||||
2. **Datenzugriff vor der Anmeldung:** `withAuth()` darf die Haushaltsgrenze nun
|
||||
auch auf `mail_tokens` überspringen. Das ist bewusst so; der Wachtest
|
||||
`tests/rls.test.ts` hält die Liste fest. `household_mail` gehört nur dem
|
||||
Haushalt.
|
||||
3. **Fehlende Konfiguration:** Ohne Mailweg gibt es keinen Versand. Die Anfrage
|
||||
antwortet trotzdem gleich, es gibt keinen Rückfall auf einen anderen Weg.
|
||||
`MAIL_TEST_DIR` setzt nur die CI. Das Chart setzt es nicht.
|
||||
4. **Wege an der Anmeldung vorbei:** keine neuen.
|
||||
|
||||
**Abdeckung** (Abschnitt 3 „Magic Link“, dazu Bremse, Sitzung und CSRF für den
|
||||
neuen Weg): 14 Anforderungen geprüft.
|
||||
- 13 erfüllt, 0 verletzt. Vorher waren es 4, sie sind in diesem PR behoben.
|
||||
- 1 nicht angestrebt (6.6.2, Bindung des Links an das anfragende Gerät): Der
|
||||
Link soll auch auf einem anderen Gerät gehen.
|
||||
|
||||
## Sofort beheben
|
||||
|
||||
Keine.
|
||||
|
||||
## In diesem PR behoben
|
||||
|
||||
### 1. Mail-Kontingent und Postfach ließen sich fluten — niedrig (ASVS 6.3.1, 6.6.3)
|
||||
**Wo:** `app/api/auth/mail/request/route.ts`
|
||||
**Was passierte:** Mit wechselnden IPs ließen sich an eine bekannte, bestätigte
|
||||
Adresse rund 280 Mails am Tag schicken. Insgesamt waren bis zu 60 Anfragen je
|
||||
Viertelstunde möglich. Das reicht, um das Tageskontingent von Resend zu
|
||||
verbrauchen und die Person zu nerven.
|
||||
**Fix:** Je Adresse 3 Anfragen in 15 Minuten und 10 am Tag; gemeinsamer Topf
|
||||
30 Anfragen je Stunde; je IP wie bisher 10 in 15 Minuten.
|
||||
|
||||
### 2. „Adresse gehört schon jemand anderem“ verriet Konten — niedrig (ASVS 6.3.7)
|
||||
**Wo:** `app/api/me/email/route.ts`
|
||||
**Was passierte:** Wer angemeldet war, konnte durch Eintragen fremder Adressen
|
||||
prüfen, wer auf der Box ein Konto hat, auch in anderen Haushalten.
|
||||
**Fix:** Die Antwort ist immer gleich. Der Link in der Bestätigungsmail greift
|
||||
dann nicht (`consumeMailToken` prüft die Adresse).
|
||||
|
||||
### 3. Mail-Sitzungen überlebten das Entfernen der Adresse — niedrig (ASVS 7.4.x)
|
||||
**Wo:** `app/api/me/email/route.ts`, `lib/auth/mail-login.ts`
|
||||
**Was passierte:** Wer merkt, dass jemand sein Postfach mitliest, und die
|
||||
Adresse entfernt, beendete damit nicht die Sitzung, die über diese Adresse
|
||||
begann.
|
||||
**Fix:** Adresse entfernen oder eine neue bestätigen beendet alle Sitzungen mit
|
||||
`via = 'mail'`.
|
||||
|
||||
### 4. Mail-Sitzungen lebten so lange wie Passkey-Sitzungen — niedrig (ASVS 7.3.x)
|
||||
**Wo:** `lib/auth/session.ts`
|
||||
**Fix:** Mail-Sitzungen gelten 30 Tage gleitend statt 180.
|
||||
|
||||
Dazu als Härtung: Der Absendername wird ohne Steuerzeichen und Anführungszeichen
|
||||
in den Mailkopf gesetzt, damit niemand über das Feld einen eigenen Kopf
|
||||
einschleust. Ein Test wacht darüber.
|
||||
|
||||
## Bald angehen
|
||||
|
||||
Nichts Neues. Aus dem letzten Lauf sind weiter offen:
|
||||
- `kein-anmeldeprotokoll`
|
||||
- `keine-csp-hsts`
|
||||
- `sitzung-ohne-hoechstdauer`
|
||||
|
||||
## Später / Härtung
|
||||
|
||||
- **Antwortzeit:** Für eine bekannte Adresse legt die Anfrage zusätzlich einen
|
||||
Token an, das sind einige Millisekunden. Der Versand selbst läuft im
|
||||
Hintergrund. Über das Netz der Box lässt sich der Unterschied kaum messen.
|
||||
Bewertung: Info.
|
||||
- **Mail-Scanner:** Sie verbrauchen keine Links, weil das Einlösen einen Tipp
|
||||
braucht. Ein Scanner, der Knöpfe drückt, würde die Person in seinem Browser
|
||||
anmelden, nicht im Browser des Angreifers. Bewertung: Info.
|
||||
|
||||
## Offene Fragen
|
||||
|
||||
- **Echter Versand** über Resend. Erst prüfbar, wenn Kai den Schlüssel eingetragen
|
||||
hat: Testmail schicken, SPF, DKIM und DMARC von `foodplanhero.de` für Resend
|
||||
prüfen.
|
||||
- **Öffentlicher Weg auf der Box:** `/anmelden/mail` hinter Envoy und Authelia
|
||||
einmal ausprobieren (CLAUDE.md, Plattform 4).
|
||||
|
||||
## Was gut ist
|
||||
|
||||
- Nur der Hash des Tokens wird gespeichert. Ein Link gilt einmal: 15 Minuten
|
||||
zum Anmelden, 24 Stunden zum Bestätigen. Ein neuer Link macht ältere ungültig.
|
||||
- Die Adresse im Link kommt aus `instance`, nie aus dem Host-Kopf. Damit kann
|
||||
niemand den Link über einen gefälschten Host auf eine fremde Seite umbiegen.
|
||||
- Die Antwort auf „Link schicken“ ist immer gleich und schnell, weil der Versand
|
||||
im Hintergrund läuft.
|
||||
- Nach dem Öffnen nimmt `history.replaceState` den Token aus der Adresszeile.
|
||||
- `noMailSession` sitzt an jedem Weg, der Zugang schafft oder entzieht. Der
|
||||
Browser-Test prüft vier davon mit echter Mail-Sitzung.
|
||||
- **Der Resend-Schlüssel**
|
||||
- geht nur hinein,
|
||||
- liegt verschlüsselt im Tresor,
|
||||
- wird nie zurückgegeben,
|
||||
- steht nicht in der Seite (Test).
|
||||
- Mails kommen ohne Bilder von außen und ohne Tracking. Alle Werte im HTML sind
|
||||
escaped (Test).
|
||||
@@ -208,6 +208,8 @@ test.describe("recipe link", () => {
|
||||
await amounts.nth(3).fill("50");
|
||||
await page.getByRole("button", { name: "Speichern" }).click();
|
||||
await expect(page.getByRole("heading", { level: 1 })).toHaveText("Linsensuppe vom Blog");
|
||||
// Gespeichert unter „Ausprobieren“ — und die Seite sagt es (26.11.41).
|
||||
await expect(page.getByRole("note").filter({ hasText: "Steht unter „Ausprobieren“" })).toBeVisible();
|
||||
await expect(page.locator("main img").first()).toHaveAttribute("src", /\/api\/fotos\//);
|
||||
await expect(page.locator(`main a[href="${origin}/rezept"]`)).toBeVisible();
|
||||
});
|
||||
@@ -467,3 +469,41 @@ test("spoons and cans: the ingredient preselects its measure, the dish shows spo
|
||||
await page.getByRole("button", { name: "Entfernen" }).click();
|
||||
await expect(page).toHaveURL(/entfernt=/);
|
||||
});
|
||||
|
||||
// Kai: „Neue Gerichte werden nicht gespeichert“ — sie standen unter „Ausprobieren“, ohne dass
|
||||
// die Seite es sagte (26.11.41). Jetzt: Hinweis, Weg dorthin, und mit einem Tipp in den Pool.
|
||||
test("a dish to try says so, links to its tab and moves to the pool with one tap", async ({ page }) => {
|
||||
await page.goto("/gerichte/neu");
|
||||
await page.fill("#title", "Probe-Auflauf");
|
||||
await page.getByRole("combobox", { name: "Zutat suchen" }).first().fill("Zwieb");
|
||||
await page.getByRole("option", { name: "Zwiebeln", exact: true }).click();
|
||||
await page.getByRole("textbox", { name: "Menge", exact: true }).first().fill("2");
|
||||
await page.getByLabel("Erst mal ausprobieren").check();
|
||||
await page.getByRole("button", { name: "Speichern" }).click();
|
||||
await expect(page.getByRole("heading", { level: 1 })).toHaveText("Probe-Auflauf");
|
||||
const note = page.getByRole("note").filter({ hasText: "Steht unter „Ausprobieren“" });
|
||||
await expect(note).toBeVisible();
|
||||
await expect(page.locator("main").getByRole("link", { name: "Gerichte", exact: true })).toHaveAttribute("href", "/gerichte?ansicht=ausprobieren");
|
||||
await note.getByRole("button", { name: "In den Pool" }).click();
|
||||
await expect(note).toHaveCount(0);
|
||||
// Fotos auch aus der Mediathek, mehrere auf einmal (26.11.43): kein capture, multiple.
|
||||
const picker = page.locator("input[type=file]");
|
||||
expect(await picker.getAttribute("capture")).toBeNull();
|
||||
expect(await picker.getAttribute("multiple")).not.toBeNull();
|
||||
const shots = await Promise.all(
|
||||
[[200, 80, 60], [60, 140, 90]].map(async ([r, g, b], i) => ({
|
||||
name: `mediathek-${i}.png`,
|
||||
mimeType: "image/png",
|
||||
buffer: await sharp({ create: { width: 800, height: 600, channels: 3, background: { r: r!, g: g!, b: b! } } }).png().toBuffer(),
|
||||
})),
|
||||
);
|
||||
await picker.setInputFiles(shots);
|
||||
await expect(page.getByRole("heading", { name: "Fotos · 2 von 5" })).toBeVisible();
|
||||
await page.goto("/gerichte");
|
||||
await expect(page.getByRole("link", { name: /Probe-Auflauf/ })).toBeVisible();
|
||||
// Aufräumen, damit der Plan danach denselben Bestand vorschlägt.
|
||||
await page.getByRole("link", { name: /Probe-Auflauf/ }).click();
|
||||
await page.getByRole("button", { name: "Entfernen" }).click();
|
||||
await expect(page).toHaveURL(/entfernt=/);
|
||||
});
|
||||
|
||||
@@ -73,29 +73,51 @@ test("scrolling never moves the bar, even while the address bar comes and goes",
|
||||
}
|
||||
});
|
||||
|
||||
test("after typing, a stale gap is bridged briefly and dropped at the first touch", async ({ page }) => {
|
||||
const shiftOf = (page: Page) => page.getByRole("navigation", { name: "Navigation" }).evaluate((el) => (el as HTMLElement).style.transform);
|
||||
const kbShift = (page: Page) => page.evaluate(() => document.documentElement.style.getPropertyValue("--kb-shift"));
|
||||
|
||||
// 26.11.41 (Kai, Bild: Leiste und „Speichern“ mitten im Bild): iOS rechnet nach der
|
||||
// Tastatur in der Web-App manchmal lange zu kurz — auch nach Berührung und Scrollen.
|
||||
test("after typing, a stuck keyboard gap stays bridged through touch and scroll until iOS recovers", async ({ page }) => {
|
||||
await page.goto("/mehr");
|
||||
const field = page.locator("#kid-name");
|
||||
await field.focus();
|
||||
await expect(page.getByRole("navigation", { name: "Navigation" })).toBeHidden(); // beim Tippen weg
|
||||
// iOS lässt das Layout nach dem Schließen der Tastatur 300 px zu kurz stehen.
|
||||
await moveViewport(page, 300);
|
||||
await moveViewport(page, 300); // iOS lässt das Layout 300 px zu kurz stehen
|
||||
await field.blur();
|
||||
const nav = page.getByRole("navigation", { name: "Navigation" });
|
||||
await expect(nav).toBeVisible();
|
||||
await expect.poll(() => nav.evaluate((el) => (el as HTMLElement).style.transform)).toBe("translateY(300px)");
|
||||
await expect.poll(() => shiftOf(page)).toBe("translateY(300px)");
|
||||
await expect.poll(() => kbShift(page)).toBe("300px");
|
||||
// Berühren, scrollen, über die erste Sekunde hinaus: bleibt unten.
|
||||
await page.evaluate(() => window.dispatchEvent(new Event("touchstart")));
|
||||
await expect.poll(() => nav.evaluate((el) => (el as HTMLElement).style.transform)).toBe("");
|
||||
await page.evaluate(() => window.dispatchEvent(new Event("touchend")));
|
||||
await page.mouse.wheel(0, 400);
|
||||
await page.waitForTimeout(1300);
|
||||
await moveViewport(page, 300);
|
||||
await expect.poll(() => shiftOf(page)).toBe("translateY(300px)");
|
||||
// iOS rechnet wieder richtig: Korrektur weg, Leiste unten.
|
||||
await moveViewport(page, 0);
|
||||
await expect.poll(() => shiftOf(page)).toBe("");
|
||||
await expect.poll(() => kbShift(page)).toBe("");
|
||||
await navAtBottom(page);
|
||||
// Danach ist nichts mehr scharf: eine neue Lücke ohne Tippen bleibt unberührt.
|
||||
await moveViewport(page, 300);
|
||||
await page.waitForTimeout(100);
|
||||
expect(await shiftOf(page)).toBe("");
|
||||
});
|
||||
|
||||
test("the bridge ends by itself after a second, and never starts without typing", async ({ page }) => {
|
||||
test("never without typing; after the first second only a keyboard-sized gap counts", async ({ page }) => {
|
||||
await page.goto("/mehr");
|
||||
const nav = page.getByRole("navigation", { name: "Navigation" });
|
||||
await moveViewport(page, 300); // ohne Tastatur: nichts tun
|
||||
await page.waitForTimeout(100);
|
||||
expect(await nav.evaluate((el) => (el as HTMLElement).style.transform)).toBe("");
|
||||
expect(await shiftOf(page)).toBe("");
|
||||
await moveViewport(page, 0);
|
||||
await page.locator("#kid-name").focus();
|
||||
await page.locator("#kid-name").blur();
|
||||
await expect.poll(() => nav.evaluate((el) => (el as HTMLElement).style.transform)).toBe("translateY(300px)");
|
||||
await expect.poll(() => nav.evaluate((el) => (el as HTMLElement).style.transform), { timeout: 3000 }).toBe("");
|
||||
await page.waitForTimeout(1300);
|
||||
// Gummiband oder Rundung (unter STUCK_MIN): Lunch fasst die Leiste nicht an.
|
||||
await moveViewport(page, 80);
|
||||
await page.waitForTimeout(100);
|
||||
expect(await shiftOf(page)).toBe("");
|
||||
await moveViewport(page, 0);
|
||||
await navAtBottom(page);
|
||||
});
|
||||
@@ -0,0 +1,108 @@
|
||||
import { readdir, readFile } from "node:fs/promises";
|
||||
import path from "node:path";
|
||||
import { expect, test, type Browser, type Page } from "@playwright/test";
|
||||
|
||||
// Anmelden per Link aus der Mail (26.11.40, Kai: Resend). Der Server schreibt jede
|
||||
// Mail nach $LUNCH_DATA/mails (MAIL_TEST_DIR) statt sie zu senden.
|
||||
test.describe.configure({ mode: "serial" });
|
||||
|
||||
const DIR = path.join(process.env.LUNCH_DATA ?? "", "mails");
|
||||
const KAI = "kai@test.example";
|
||||
|
||||
async function mails(to: string): Promise<{ to: string; text: string; subject: string }[]> {
|
||||
const files = (await readdir(DIR).catch(() => [])).sort();
|
||||
const all = await Promise.all(files.map(async (f) => JSON.parse(await readFile(path.join(DIR, f), "utf8"))));
|
||||
return all.filter((m) => m.to === to);
|
||||
}
|
||||
const linkIn = (text: string) => text.match(/https?:\/\/\S+\/anmelden\/mail#\S+/)![0];
|
||||
|
||||
async function fresh(browser: Browser): Promise<Page> {
|
||||
const context = await browser.newContext({ ...test.info().project.use, storageState: undefined });
|
||||
return context.newPage();
|
||||
}
|
||||
|
||||
test("the admin sets up sending with Resend and sends a test mail", async ({ page }) => {
|
||||
await page.goto("/mehr");
|
||||
await expect(page.getByRole("link", { name: /Noch nicht eingerichtet/ })).toBeVisible();
|
||||
await page.goto("/mehr/mail");
|
||||
await expect(page.getByLabel("Server")).toHaveValue("smtp.resend.com");
|
||||
await expect(page.getByLabel("Port", { exact: true })).toHaveValue("465");
|
||||
await expect(page.getByLabel("Benutzer")).toHaveValue("resend");
|
||||
await expect(page.getByLabel("Absender", { exact: true })).toHaveValue("hallo@foodplanhero.de");
|
||||
await page.getByLabel("API-Schlüssel").fill("re_test_not_a_real_key");
|
||||
await page.getByRole("button", { name: "Speichern" }).click();
|
||||
await expect(page.getByText("Ein Schlüssel ist gespeichert.")).toBeVisible();
|
||||
// Der Schlüssel kommt nie zurück in die Seite.
|
||||
expect(await page.content()).not.toContain("re_test_not_a_real_key");
|
||||
await page.getByLabel("Testmail an").fill(KAI);
|
||||
await page.getByRole("button", { name: "Testmail schicken" }).click();
|
||||
await expect(page.getByRole("status")).toContainText("Die Testmail ist unterwegs.");
|
||||
expect((await mails(KAI)).at(-1)?.subject).toBe("Testmail von foodplanhero");
|
||||
});
|
||||
|
||||
test("a person confirms the address through the first link", async ({ page }) => {
|
||||
await page.goto("/mehr");
|
||||
const section = page.locator("#mail");
|
||||
await section.getByLabel("Deine Mailadresse").fill(KAI);
|
||||
await section.getByRole("button", { name: "Bestätigung schicken" }).click();
|
||||
await expect(section.getByRole("status")).toContainText(`Wartet auf Bestätigung: ${KAI}`);
|
||||
const verify = (await mails(KAI)).at(-1)!;
|
||||
expect(verify.subject).toBe("Bitte bestätige deine Adresse");
|
||||
await page.goto(linkIn(verify.text));
|
||||
await expect(page.getByRole("heading", { level: 1 })).toHaveText("Adresse bestätigen");
|
||||
// Der Token verschwindet aus der Adresszeile.
|
||||
expect(page.url()).not.toContain("#");
|
||||
await page.getByRole("button", { name: "Bestätigen" }).click();
|
||||
await expect(page.getByRole("heading", { level: 1 })).toHaveText("Deine Adresse ist bestätigt.");
|
||||
await page.goto("/mehr");
|
||||
await expect(page.locator("#mail")).toContainText(`Bestätigt: ${KAI}`);
|
||||
});
|
||||
|
||||
test("signed out: a link by mail signs in once; unknown addresses get the same answer and no mail", async ({ browser }) => {
|
||||
const page = await fresh(browser);
|
||||
const sent = "Wenn die Adresse bei uns bestätigt ist, kommt gleich eine Mail.";
|
||||
await page.goto("/anmelden");
|
||||
await page.getByRole("button", { name: "Lieber einen Link per Mail?" }).click();
|
||||
await page.getByLabel("Deine Mailadresse").fill("niemand@test.example");
|
||||
await page.getByRole("button", { name: "Link schicken" }).click();
|
||||
await expect(page.getByRole("status")).toContainText(sent);
|
||||
expect(await mails("niemand@test.example")).toHaveLength(0);
|
||||
|
||||
const before = (await mails(KAI)).length;
|
||||
await page.goto("/anmelden");
|
||||
await page.getByRole("button", { name: "Lieber einen Link per Mail?" }).click();
|
||||
await page.getByLabel("Deine Mailadresse").fill(KAI.toUpperCase());
|
||||
await page.getByRole("button", { name: "Link schicken" }).click();
|
||||
await expect(page.getByRole("status")).toContainText(sent);
|
||||
await expect.poll(async () => (await mails(KAI)).length).toBe(before + 1);
|
||||
const link = linkIn((await mails(KAI)).at(-1)!.text);
|
||||
|
||||
await page.goto(link);
|
||||
await expect(page.getByRole("heading", { level: 1 })).toHaveText("Bei foodplanhero anmelden");
|
||||
await page.getByRole("button", { name: "Anmelden" }).click();
|
||||
await expect(page).toHaveURL(/\/$/);
|
||||
|
||||
// Per Mail angemeldet: nur anmelden — kein Gerätelink, keine Einladung, keine Adresse ändern.
|
||||
await page.goto("/mehr");
|
||||
await expect(page.getByText("Du bist per Mail-Link angemeldet.").first()).toBeVisible();
|
||||
const status = await page.evaluate(async () =>
|
||||
Promise.all(
|
||||
[
|
||||
["/api/household/invitations", "POST", { kind: "device" }],
|
||||
["/api/household/invitations", "POST", { kind: "person", name: "Gast" }],
|
||||
["/api/me/email", "PUT", { email: "neu@test.example" }],
|
||||
["/api/household/kid-devices", "POST", { label: "Tablet", kind: "kids" }],
|
||||
].map(async ([url, method, body]) => {
|
||||
const res = await fetch(url as string, { method: method as string, headers: { "content-type": "application/json" }, body: JSON.stringify(body) });
|
||||
return `${res.status} ${(await res.json()).error}`;
|
||||
}),
|
||||
),
|
||||
);
|
||||
expect(status).toEqual(["403 mailSession", "403 mailSession", "403 mailSession", "403 mailSession"]);
|
||||
|
||||
// Derselbe Link ein zweites Mal: verbraucht.
|
||||
const again = await fresh(browser);
|
||||
await again.goto(link);
|
||||
await again.getByRole("button", { name: "Anmelden" }).click();
|
||||
await expect(again.getByRole("heading", { level: 1 })).toHaveText("Dieser Link gilt nicht mehr");
|
||||
});
|
||||
@@ -19,6 +19,7 @@ const SIGNED_IN = [
|
||||
{ path: "/gerichte/foto", heading: "Kochbuch fotografieren" },
|
||||
{ path: "/gerichte/sprechen", heading: "Gericht einsprechen" },
|
||||
{ path: "/mehr/ki", heading: "AI" },
|
||||
{ path: "/mehr/mail", heading: "Mails verschicken" },
|
||||
{ path: "/wuenschen", heading: "Wünschen" },
|
||||
{ path: "/plan", heading: "Plan" },
|
||||
{ path: "/einkauf", heading: "Einkaufsliste" },
|
||||
@@ -27,6 +28,7 @@ const SIGNED_IN = [
|
||||
const SIGNED_OUT = [
|
||||
{ path: "/anmelden", heading: "Anmelden" },
|
||||
{ path: "/wiederherstellen", heading: "Zugang wiederherstellen" },
|
||||
{ path: "/anmelden/mail", heading: "Dieser Link gilt nicht mehr" },
|
||||
{ path: "/kinder", heading: "Kein Kindergerät" },
|
||||
{ path: "/offline", heading: "Kein Netz" },
|
||||
];
|
||||
|
||||
@@ -21,6 +21,15 @@ export async function guardWrite(request: Request, roles: Role[] = WRITERS): Pro
|
||||
return session;
|
||||
}
|
||||
|
||||
/**
|
||||
* Wege, die Zugang schaffen oder entziehen (Geräte, Passkeys, Einladungen,
|
||||
* Kindergeräte, Küchendisplay, Mailweg): nie aus einer Sitzung, die per Mail-Link
|
||||
* begann — sonst wäre jedes Konto nur so sicher wie das Postfach (E-0006, E-0017).
|
||||
*/
|
||||
export function noMailSession(session: Session): Response | null {
|
||||
return session.via === "mail" ? fail("mailSession", 403) : null;
|
||||
}
|
||||
|
||||
/** Für lesende Routen: nur die Sitzung. */
|
||||
export async function guardRead(): Promise<Session | Response> {
|
||||
return (await getSession()) ?? fail("signedOut", 401);
|
||||
|
||||
@@ -0,0 +1,98 @@
|
||||
import "server-only";
|
||||
import type { PoolClient } from "pg";
|
||||
import { getTranslations } from "next-intl/server";
|
||||
import { isLocale } from "@/lib/locale";
|
||||
import { buttonMail, sendMail } from "@/lib/mail";
|
||||
import { hashToken, randomToken } from "./tokens";
|
||||
|
||||
// Anmelden per Link aus der Mail (26.11.40, E-0006, E-0017). Ein Link gilt einmal
|
||||
// und kurz; gespeichert ist nur sein Hash. Er öffnet /anmelden/mail#login=…, und
|
||||
// erst ein Tipp dort löst ihn per POST ein — ein Mail-Scanner, der Links nur
|
||||
// abruft, verbraucht ihn nicht, und der Token steht in keinem Server-Log.
|
||||
// Die Adresse im Link kommt aus der Tabelle instance, nie aus dem Host-Kopf.
|
||||
|
||||
export type Purpose = "login" | "verify";
|
||||
const LIFETIME_MINUTES: Record<Purpose, number> = { login: 15, verify: 24 * 60 };
|
||||
/** Wer sich per Mail anmelden darf: Erwachsene und Jugendliche, keine Kinder, keine Gäste. */
|
||||
const MAIL_ROLES = ["admin", "member", "teen"];
|
||||
|
||||
export const normalizeEmail = (email: string) => email.trim().toLowerCase();
|
||||
|
||||
/** Legt einen Einmal-Link an; ältere, unbenutzte desselben Zwecks verfallen. Gibt den Klartext-Token zurück. */
|
||||
export async function createMailToken(
|
||||
client: PoolClient,
|
||||
t: { householdId: string; memberId: string; purpose: Purpose; email: string },
|
||||
): Promise<string> {
|
||||
await client.query("delete from mail_tokens where expires_at < now() - interval '1 day'");
|
||||
await client.query("update mail_tokens set used_at = now() where member_id = $1 and purpose = $2 and used_at is null", [t.memberId, t.purpose]);
|
||||
const token = randomToken();
|
||||
await client.query(
|
||||
`insert into mail_tokens (household_id, member_id, purpose, email, token_hash, expires_at)
|
||||
values ($1, $2, $3, $4, $5, now() + make_interval(mins => $6))`,
|
||||
[t.householdId, t.memberId, t.purpose, t.email, hashToken(token), LIFETIME_MINUTES[t.purpose]],
|
||||
);
|
||||
return token;
|
||||
}
|
||||
|
||||
/** Wem gehört eine bestätigte Adresse, die sich per Mail anmelden darf? Läuft in withAuth. */
|
||||
export async function findMailMember(client: PoolClient, email: string) {
|
||||
const { rows } = await client.query(
|
||||
`select id, household_id as "householdId", locale from members
|
||||
where email = $1 and email_verified_at is not null and role = any($2::text[])`,
|
||||
[email, MAIL_ROLES],
|
||||
);
|
||||
return (rows[0] ?? null) as { id: string; householdId: string; locale: string | null } | null;
|
||||
}
|
||||
|
||||
export type Consumed = { purpose: Purpose; memberId: string; householdId: string; email: string };
|
||||
|
||||
/**
|
||||
* Löst einen Link ein: gültig, unbenutzt, und die Adresse gehört noch der Person
|
||||
* (beim Anmelden: weiterhin bestätigt). Danach ist er verbraucht. Läuft in withAuth.
|
||||
*/
|
||||
export async function consumeMailToken(client: PoolClient, token: string): Promise<Consumed | null> {
|
||||
const { rows } = await client.query(
|
||||
`update mail_tokens set used_at = now()
|
||||
where token_hash = $1 and used_at is null and expires_at > now()
|
||||
returning purpose, member_id as "memberId", household_id as "householdId", email`,
|
||||
[hashToken(token)],
|
||||
);
|
||||
const hit = rows[0] as Consumed | undefined;
|
||||
if (!hit) return null;
|
||||
if (hit.purpose === "login") {
|
||||
const member = await findMailMember(client, hit.email);
|
||||
return member?.id === hit.memberId ? hit : null;
|
||||
}
|
||||
// Bestätigen: Gehört die Adresse inzwischen jemand anderem, gilt der Link nicht.
|
||||
const taken = await client.query("select 1 from members where email = $1 and id <> $2", [hit.email, hit.memberId]);
|
||||
if (taken.rowCount) return null;
|
||||
const before = (await client.query("select email from members where id = $1", [hit.memberId])).rows[0]?.email as string | null;
|
||||
const { rowCount } = await client.query(
|
||||
"update members set email = $2, email_verified_at = now() where id = $1 and role = any($3::text[])",
|
||||
[hit.memberId, hit.email, MAIL_ROLES],
|
||||
);
|
||||
// Neue Adresse: Sitzungen, die über die alte begannen, enden.
|
||||
if (rowCount && before && before !== hit.email) await client.query("delete from sessions where member_id = $1 and via = 'mail'", [hit.memberId]);
|
||||
return rowCount ? hit : null;
|
||||
}
|
||||
|
||||
/** Die Mail mit dem Link, in der Sprache der Person. */
|
||||
export async function linkMail(p: { purpose: Purpose; to: string; token: string; origin: string; locale: string | null }) {
|
||||
const locale = isLocale(p.locale) ? p.locale : "de";
|
||||
const t = await getTranslations({ locale, namespace: `mail.${p.purpose}` });
|
||||
return buttonMail({
|
||||
to: p.to,
|
||||
subject: t("subject"),
|
||||
lead: t("lead"),
|
||||
button: t("button"),
|
||||
url: `${p.origin}/anmelden/mail#${p.purpose}=${p.token}`,
|
||||
note: t("note"),
|
||||
});
|
||||
}
|
||||
|
||||
/** Verschickt im Hintergrund: Die Antwort darf nicht verraten, ob es die Adresse gibt — auch nicht durch ihre Dauer. */
|
||||
export function sendInBackground(householdId: string, mail: Promise<Parameters<typeof sendMail>[1]>) {
|
||||
void mail
|
||||
.then((m) => sendMail(householdId, m))
|
||||
.catch((error) => console.error("mail: Versand fehlgeschlagen", (error as Error).message));
|
||||
}
|
||||
@@ -14,6 +14,9 @@ import { hashToken, randomToken } from "./tokens";
|
||||
|
||||
export const SESSION_COOKIE = "lunch_session";
|
||||
const LIFETIME_DAYS = 180;
|
||||
/** Per Mail-Link begonnen: kürzer, weil das Postfach der einzige Faktor ist (26.11.40). */
|
||||
const MAIL_LIFETIME_DAYS = 30;
|
||||
const lifetime = (via: string) => (via === "mail" ? MAIL_LIFETIME_DAYS : LIFETIME_DAYS);
|
||||
|
||||
export type Session = {
|
||||
sessionId: string;
|
||||
@@ -22,29 +25,34 @@ export type Session = {
|
||||
displayName: string;
|
||||
role: Role;
|
||||
householdName: string;
|
||||
/** Womit die Sitzung begann. „mail“ darf nur anmelden: keine Geräte, Passkeys, Einladungen (E-0006). */
|
||||
via: "passkey" | "mail" | "kid";
|
||||
};
|
||||
|
||||
/** Legt eine Sitzung an und setzt den Keks. Aufruf in einer withAuth-Transaktion. */
|
||||
export async function startSession(
|
||||
client: PoolClient,
|
||||
// Begonnen mit einem Passkey (Erwachsene) oder auf einem Kindergerät (lib/auth/kids.ts).
|
||||
member: { id: string; householdId: string; passkeyId?: string; kidDeviceId?: string },
|
||||
member: { id: string; householdId: string; passkeyId?: string; kidDeviceId?: string; viaMail?: boolean },
|
||||
request: Request,
|
||||
secure: boolean,
|
||||
): Promise<void> {
|
||||
const { rows } = await client.query("select locale from members where id = $1", [member.id]);
|
||||
const token = randomToken();
|
||||
const via = member.kidDeviceId ? "kid" : member.viaMail ? "mail" : "passkey";
|
||||
const days = lifetime(via);
|
||||
await client.query(
|
||||
`insert into sessions (token_hash, member_id, household_id, passkey_id, kid_device_id, user_agent, expires_at)
|
||||
values ($1, $2, $3, $4, $7, $5, now() + make_interval(days => $6))`,
|
||||
`insert into sessions (token_hash, member_id, household_id, passkey_id, kid_device_id, user_agent, expires_at, via)
|
||||
values ($1, $2, $3, $4, $7, $5, now() + make_interval(days => $6), $8)`,
|
||||
[
|
||||
hashToken(token),
|
||||
member.id,
|
||||
member.householdId,
|
||||
member.passkeyId ?? null,
|
||||
request.headers.get("user-agent")?.slice(0, 300) ?? null,
|
||||
LIFETIME_DAYS,
|
||||
days,
|
||||
member.kidDeviceId ?? null,
|
||||
via,
|
||||
],
|
||||
);
|
||||
(await cookies()).set(SESSION_COOKIE, token, {
|
||||
@@ -52,7 +60,7 @@ export async function startSession(
|
||||
secure,
|
||||
sameSite: "lax",
|
||||
path: "/",
|
||||
maxAge: LIFETIME_DAYS * 24 * 60 * 60,
|
||||
maxAge: days * 24 * 60 * 60,
|
||||
});
|
||||
// Die Sprache gehört der Person: Was sie gewählt hat, gilt auf jedem Gerät.
|
||||
const locale = rows[0]?.locale;
|
||||
@@ -65,7 +73,7 @@ export async function getSession(): Promise<Session | null> {
|
||||
if (!token) return null;
|
||||
return withAuth(async (client) => {
|
||||
const { rows } = await client.query(
|
||||
`select s.id, s.member_id, s.household_id, s.last_seen_at < now() - interval '1 day' as stale,
|
||||
`select s.id, s.member_id, s.household_id, s.via, s.last_seen_at < now() - interval '1 day' as stale,
|
||||
m.display_name, m.role, h.name as household_name
|
||||
from sessions s
|
||||
join members m on m.id = s.member_id
|
||||
@@ -78,7 +86,7 @@ export async function getSession(): Promise<Session | null> {
|
||||
if (row.stale) {
|
||||
await client.query(
|
||||
"update sessions set last_seen_at = now(), expires_at = now() + make_interval(days => $2) where id = $1",
|
||||
[row.id, LIFETIME_DAYS],
|
||||
[row.id, lifetime(row.via)],
|
||||
);
|
||||
}
|
||||
return {
|
||||
@@ -88,6 +96,7 @@ export async function getSession(): Promise<Session | null> {
|
||||
displayName: row.display_name,
|
||||
role: row.role,
|
||||
householdName: row.household_name,
|
||||
via: row.via,
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
@@ -46,6 +46,7 @@ export const TABLES = [
|
||||
"helper_points",
|
||||
"achievements",
|
||||
"household_ai", // Schlüssel verschlüsselt: gehört mit tresor.key zusammen
|
||||
"household_mail", // ebenso: Resend-Schlüssel verschlüsselt (26.11.40)
|
||||
] as const;
|
||||
|
||||
/** Tabellen, die globale und eigene Zeilen mischen: nur die eigenen in den Abzug. */
|
||||
@@ -57,6 +58,7 @@ export const EXCLUDED: Record<string, string> = {
|
||||
sessions: "kurzlebig; nach dem Zurückspielen meldet sich jede Person mit ihrem Passkey neu an",
|
||||
auth_challenges: "lebt fünf Minuten",
|
||||
auth_attempts: "Bremse, lebt einen Tag",
|
||||
mail_tokens: "Einmal-Links aus der Mail, gelten höchstens einen Tag",
|
||||
schema_migrations: "gehört zur Datenbank, nicht zu den Daten",
|
||||
starter_dishes: "Vorlage aus db/seed, wird bei jedem Start eingespielt",
|
||||
starter_dish_ingredients: "Vorlage aus db/seed",
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
// Version der App-Symbole (docs/icon/lunch.svg → scripts/app-icons.mjs). Ändert sich
|
||||
// das Symbol, hier hochzählen: Die Adressen ändern sich, Browser und Service Worker
|
||||
// holen das neue statt des gemerkten (26.11.42, Kochmütze mit Herz).
|
||||
export const ICON_VERSION = "2";
|
||||
export const iconUrl = (path: string) => `${path}?v=${ICON_VERSION}`;
|
||||
@@ -0,0 +1,82 @@
|
||||
import "server-only";
|
||||
import { randomBytes } from "node:crypto";
|
||||
import { mkdir, writeFile } from "node:fs/promises";
|
||||
import path from "node:path";
|
||||
import nodemailer from "nodemailer";
|
||||
import type { PoolClient } from "pg";
|
||||
import { withHousehold } from "./db";
|
||||
import { unseal } from "./vault";
|
||||
|
||||
// Mails verschicken (26.11.40): je Haushalt ein SMTP-Zugang, Standard Resend
|
||||
// (smtp.resend.com, 465, Benutzer „resend“, Passwort = API-Schlüssel). Der
|
||||
// Schlüssel liegt nur verschlüsselt in household_mail (lib/vault.ts).
|
||||
// Nur für die Tests: MAIL_TEST_DIR schreibt jede Mail als JSON statt zu senden.
|
||||
|
||||
export const RESEND = { host: "smtp.resend.com", port: 465, secure: true, username: "resend" } as const;
|
||||
|
||||
export type MailSettings = {
|
||||
host: string;
|
||||
port: number;
|
||||
secure: boolean;
|
||||
username: string;
|
||||
passwordEnc: Buffer | null;
|
||||
fromAddress: string;
|
||||
fromName: string | null;
|
||||
};
|
||||
|
||||
export type Mail = { to: string; subject: string; text: string; html: string };
|
||||
|
||||
export class MailNotConfigured extends Error {
|
||||
constructor() {
|
||||
super("notConfigured");
|
||||
}
|
||||
}
|
||||
|
||||
export async function loadMail(client: PoolClient): Promise<MailSettings | null> {
|
||||
const { rows } = await client.query(
|
||||
`select host, port, secure, username, password_enc as "passwordEnc", from_address as "fromAddress", from_name as "fromName"
|
||||
from household_mail`,
|
||||
);
|
||||
return rows[0] ?? null;
|
||||
}
|
||||
|
||||
/** Schickt eine Mail über den Zugang des Haushalts. Wirft MailNotConfigured oder den SMTP-Fehler. */
|
||||
export async function sendMail(householdId: string, mail: Mail): Promise<void> {
|
||||
const settings = await withHousehold(householdId, loadMail);
|
||||
if (!settings?.passwordEnc) throw new MailNotConfigured();
|
||||
// Kein Anführungszeichen, kein Zeilenumbruch: nichts, was einen Kopf der Mail aufbrechen könnte.
|
||||
const display = settings.fromName?.replace(/["\\\x00-\x1f\x7f]/g, "").trim();
|
||||
const from = display ? `"${display}" <${settings.fromAddress}>` : settings.fromAddress;
|
||||
const dir = process.env.MAIL_TEST_DIR;
|
||||
if (dir) {
|
||||
await mkdir(dir, { recursive: true });
|
||||
const name = `${Date.now()}-${randomBytes(4).toString("hex")}.json`;
|
||||
await writeFile(path.join(dir, name), JSON.stringify({ from, ...mail }), { mode: 0o600 });
|
||||
return;
|
||||
}
|
||||
const transport = nodemailer.createTransport({
|
||||
host: settings.host,
|
||||
port: settings.port,
|
||||
secure: settings.secure,
|
||||
auth: { user: settings.username, pass: await unseal(settings.passwordEnc) },
|
||||
connectionTimeout: 10_000,
|
||||
greetingTimeout: 10_000,
|
||||
socketTimeout: 20_000,
|
||||
});
|
||||
await transport.sendMail({ from, to: mail.to, subject: mail.subject, text: mail.text, html: mail.html });
|
||||
}
|
||||
|
||||
const escape = (s: string) => s.replace(/[&<>"']/g, (c) => ({ "&": "&", "<": "<", ">": ">", '"': """, "'": "'" })[c]!);
|
||||
|
||||
/** Eine schlichte Mail: Satz, Knopf, Hinweis. Keine Bilder von außen, kein Tracking. */
|
||||
export function buttonMail(p: { to: string; subject: string; lead: string; button: string; url: string; note: string }): Mail {
|
||||
const text = `${p.lead}\n\n${p.url}\n\n${p.note}\n\n— foodplanhero`;
|
||||
const html = `<!doctype html><html><body style="margin:0;padding:24px;background:#faf8ff;font-family:Poppins,Helvetica,Arial,sans-serif;color:#1f1d2b">
|
||||
<div style="max-width:480px;margin:0 auto;background:#ffffff;border-radius:16px;padding:28px">
|
||||
<p style="margin:0 0 8px;font-size:20px;font-weight:700">foodplanhero</p>
|
||||
<p style="margin:0 0 24px;font-size:16px;line-height:1.5">${escape(p.lead)}</p>
|
||||
<p style="margin:0 0 24px"><a href="${escape(p.url)}" style="display:inline-block;background:#5b4a9e;color:#ffffff;text-decoration:none;font-weight:600;padding:14px 24px;border-radius:999px">${escape(p.button)}</a></p>
|
||||
<p style="margin:0;font-size:13px;line-height:1.5;color:#5e5a70">${escape(p.note)}</p>
|
||||
</div></body></html>`;
|
||||
return { to: p.to, subject: p.subject, text, html };
|
||||
}
|
||||
@@ -11,8 +11,11 @@ import { useEffect, useRef, useState } from "react";
|
||||
// Größenereignis des sichtbaren Bereichs. In Safari fährt beim Scrollen die
|
||||
// Adressleiste ein und aus, iOS meldet das verzögert — die Leiste rutschte mit
|
||||
// (Kai, 7.11.2026). Jetzt gilt: Beim Scrollen fasst Lunch die Leiste nie an.
|
||||
// Korrigiert wird nur im Fenster nach dem Schließen der Tastatur, und die erste
|
||||
// Berührung oder der erste Scroll danach nimmt die Korrektur zurück.
|
||||
// Korrigiert wird nur nach dem Schließen der Tastatur und nur in der Web-App.
|
||||
//
|
||||
// Seit 26.11.41: Die Korrektur bleibt, solange iOS den Bildschirm zu kurz rechnet —
|
||||
// erkennbar an einer Lücke in Tastaturgröße (STUCK_MIN), die das Scrollen in einer
|
||||
// Web-App sonst nie erzeugt. Kleine Lücken (Gummiband) fasst Lunch weiter nicht an.
|
||||
|
||||
/** Wie lange nach dem Schließen der Tastatur nachgemessen wird. */
|
||||
export const SETTLE_MS = 1000;
|
||||
@@ -33,6 +36,22 @@ const EDITABLE =
|
||||
|
||||
export const isEditable = (el: Element | null) => !!el && el.matches(EDITABLE);
|
||||
|
||||
/**
|
||||
* Ab dieser Lücke ist es die stehengebliebene Tastatur, kein Gummiband (26.11.41).
|
||||
* iOS-Tastaturen sind 250–400 pt hoch; Gummiband und Rundungen bleiben weit darunter.
|
||||
*/
|
||||
export const STUCK_MIN = 150;
|
||||
|
||||
/**
|
||||
* Die Korrektur nach dem Schließen der Tastatur (26.11.41, Kai: Leiste mitten im Bild,
|
||||
* auch nach dem Scrollen). Im ersten Augenblick gilt jede Lücke über 40 px; danach nur
|
||||
* noch eine in Tastaturgröße — so lange, bis iOS selbst wieder richtig rechnet.
|
||||
*/
|
||||
export function stuckShift(gap: number, settling: boolean): number {
|
||||
if (settling) return gap;
|
||||
return gap >= STUCK_MIN ? gap : 0;
|
||||
}
|
||||
|
||||
/** Liefert, ob gerade getippt wird, und eine Ref für die Leiste, die unten gehalten wird. */
|
||||
export function useKeyboardSafeNav<T extends HTMLElement>() {
|
||||
const ref = useRef<T>(null);
|
||||
@@ -45,17 +64,37 @@ export function useKeyboardSafeNav<T extends HTMLElement>() {
|
||||
|
||||
useEffect(() => {
|
||||
const vv = window.visualViewport;
|
||||
let until = 0; // Ende des Fensters nach dem Schließen der Tastatur
|
||||
const root = document.documentElement;
|
||||
// Nach dem Schließen der Tastatur scharf, bis iOS den Bildschirm wieder voll rechnet.
|
||||
// In der Web-App gibt es keine Adressleiste — eine Lücke in Tastaturgröße ist dort
|
||||
// immer der Fehler, auch noch nach Berührung und Scrollen (bis 26.11.40 ließ Lunch
|
||||
// die Korrektur bei der ersten Berührung fallen, und die Leiste sprang zurück).
|
||||
let armed = false;
|
||||
let settleUntil = 0;
|
||||
let frame = 0;
|
||||
const apply = (shift: number) => {
|
||||
if (ref.current) ref.current.style.transform = shift ? `translateY(${shift}px)` : "";
|
||||
// Klebende Knopfleisten (Speichern, Los geht's …) folgen über --kb-shift (globals.css).
|
||||
if (shift) root.style.setProperty("--kb-shift", `${shift}px`);
|
||||
else root.style.removeProperty("--kb-shift");
|
||||
};
|
||||
const clear = () => {
|
||||
until = 0;
|
||||
if (ref.current) ref.current.style.transform = "";
|
||||
armed = false;
|
||||
settleUntil = 0;
|
||||
apply(0);
|
||||
};
|
||||
const pin = () => {
|
||||
const el = ref.current;
|
||||
if (!el || !vv) return;
|
||||
if (Date.now() > until || !isStandalone()) return clear();
|
||||
const gap = keyboardGap(vv, document.documentElement.clientHeight);
|
||||
el.style.transform = gap ? `translateY(${gap}px)` : "";
|
||||
frame = 0;
|
||||
if (!armed || !vv || !isStandalone()) return clear();
|
||||
const shift = stuckShift(keyboardGap(vv, root.clientHeight), Date.now() < settleUntil);
|
||||
apply(shift);
|
||||
// iOS rechnet wieder richtig: entschärfen.
|
||||
if (!shift && Date.now() >= settleUntil) armed = false;
|
||||
};
|
||||
// Bei jedem Ereignis neu messen, nie einen alten Wert stehen lassen: Rechnet iOS
|
||||
// zwischendurch wieder richtig, fällt die Korrektur im selben Bild weg.
|
||||
const schedule = () => {
|
||||
if (armed && !frame) frame = requestAnimationFrame(pin);
|
||||
};
|
||||
const onFocusIn = (e: FocusEvent) => {
|
||||
if (isEditable(e.target as Element)) {
|
||||
@@ -68,38 +107,34 @@ export function useKeyboardSafeNav<T extends HTMLElement>() {
|
||||
setTimeout(() => {
|
||||
if (isEditable(document.activeElement)) return;
|
||||
setTyping(false);
|
||||
if (!isStandalone()) return;
|
||||
window.scrollTo(window.scrollX, window.scrollY); // stößt das Neuvermessen an
|
||||
until = Date.now() + SETTLE_MS;
|
||||
requestAnimationFrame(pin);
|
||||
setTimeout(pin, 300); // nach der Animation der Tastatur noch einmal
|
||||
setTimeout(() => {
|
||||
if (!until) return;
|
||||
clear();
|
||||
// Steht die Leiste ohne Korrektur noch falsch, iOS noch einmal neu messen lassen.
|
||||
if (vv && isStandalone() && keyboardGap(vv, document.documentElement.clientHeight)) {
|
||||
window.scrollTo(window.scrollX, window.scrollY + 1);
|
||||
window.scrollTo(window.scrollX, window.scrollY - 1);
|
||||
}
|
||||
}, SETTLE_MS + 50);
|
||||
armed = true;
|
||||
settleUntil = Date.now() + SETTLE_MS;
|
||||
schedule();
|
||||
setTimeout(schedule, 300); // nach der Animation der Tastatur noch einmal
|
||||
setTimeout(schedule, SETTLE_MS + 50); // Ende des ersten Augenblicks
|
||||
}, 50);
|
||||
};
|
||||
// Sobald die Person wieder berührt (jeder Scroll am Handy beginnt so) oder am Rad
|
||||
// dreht, gilt die Lage, die iOS selbst rechnet. Kein „scroll“: Den lösen auch das
|
||||
// scrollTo oben und iOS beim Schließen der Tastatur aus.
|
||||
const onUser = () => until && clear();
|
||||
document.addEventListener("focusin", onFocusIn);
|
||||
document.addEventListener("focusout", onFocusOut);
|
||||
vv?.addEventListener("resize", pin);
|
||||
window.addEventListener("touchstart", onUser, { passive: true });
|
||||
window.addEventListener("wheel", onUser, { passive: true });
|
||||
vv?.addEventListener("resize", schedule);
|
||||
vv?.addEventListener("scroll", schedule);
|
||||
window.addEventListener("scroll", schedule, { passive: true });
|
||||
window.addEventListener("resize", schedule);
|
||||
window.addEventListener("touchend", schedule, { passive: true });
|
||||
window.addEventListener("orientationchange", clear);
|
||||
return () => {
|
||||
if (frame) cancelAnimationFrame(frame);
|
||||
document.removeEventListener("focusin", onFocusIn);
|
||||
document.removeEventListener("focusout", onFocusOut);
|
||||
vv?.removeEventListener("resize", pin);
|
||||
window.removeEventListener("touchstart", onUser);
|
||||
window.removeEventListener("wheel", onUser);
|
||||
vv?.removeEventListener("resize", schedule);
|
||||
vv?.removeEventListener("scroll", schedule);
|
||||
window.removeEventListener("scroll", schedule);
|
||||
window.removeEventListener("resize", schedule);
|
||||
window.removeEventListener("touchend", schedule);
|
||||
window.removeEventListener("orientationchange", clear);
|
||||
clear();
|
||||
};
|
||||
}, []);
|
||||
|
||||
|
||||
@@ -49,7 +49,11 @@
|
||||
"submit": "Mit Passkey anmelden",
|
||||
"noPasskey": "Noch kein Passkey auf diesem Gerät? Lass dir im Haushalt unter Mehr › Gerät hinzufügen einen Link geben.",
|
||||
"lost": "Zugang verloren?",
|
||||
"kids": "Kinder melden sich hier an"
|
||||
"kids": "Kinder melden sich hier an",
|
||||
"mailToggle": "Lieber einen Link per Mail?",
|
||||
"mailLabel": "Deine Mailadresse",
|
||||
"mailSubmit": "Link schicken",
|
||||
"mailSent": "Wenn die Adresse bei uns bestätigt ist, kommt gleich eine Mail. Der Link gilt 15 Minuten."
|
||||
},
|
||||
"invite": {
|
||||
"title": "Einladung zu {household}",
|
||||
@@ -75,7 +79,12 @@
|
||||
"forbidden": "Das dürfen nur Admins.",
|
||||
"unknown": "Das hat nicht geklappt. Bitte versuch es noch einmal.",
|
||||
"lastPasskey": "Das ist dein letzter Passkey. Füge erst ein anderes Gerät hinzu.",
|
||||
"noBackup": "Es liegt keine Sicherung vor."
|
||||
"noBackup": "Es liegt keine Sicherung vor.",
|
||||
"mailSession": "Per Mail-Link angemeldet geht das nicht. Nimm dafür deinen Passkey.",
|
||||
"linkExpired": "Dieser Link gilt nicht mehr.",
|
||||
"emailTaken": "Diese Adresse gehört schon zu jemand anderem.",
|
||||
"mailNotConfigured": "Mails verschickt der Haushalt noch nicht. Ein Admin richtet das unter Mehr › Mails verschicken ein.",
|
||||
"mailFailed": "Die Mail ließ sich nicht verschicken. Bitte versuch es später noch einmal."
|
||||
},
|
||||
"recovery": {
|
||||
"title": "Zugang wiederherstellen",
|
||||
@@ -92,6 +101,19 @@
|
||||
"submit": "Sicherung zurückspielen",
|
||||
"otherOrigin": "Die Sicherung gehört zur Adresse {origin}. Öffne die App dort, sonst passen die Passkeys nicht.",
|
||||
"or": "Oder neu beginnen"
|
||||
},
|
||||
"mailLink": {
|
||||
"loginTitle": "Bei foodplanhero anmelden",
|
||||
"loginIntro": "Tippe auf Anmelden, und es geht los.",
|
||||
"loginSubmit": "Anmelden",
|
||||
"verifyTitle": "Adresse bestätigen",
|
||||
"verifyIntro": "Danach kannst du dich auch mit einem Link aus der Mail anmelden.",
|
||||
"verifySubmit": "Bestätigen",
|
||||
"verified": "Deine Adresse ist bestätigt.",
|
||||
"toMore": "Weiter",
|
||||
"expiredTitle": "Dieser Link gilt nicht mehr",
|
||||
"expiredIntro": "Links aus der Mail gelten einmal und nur kurz. Fordere einfach einen neuen an.",
|
||||
"back": "Zur Anmeldung"
|
||||
}
|
||||
},
|
||||
"more": {
|
||||
@@ -249,6 +271,44 @@
|
||||
"saved": "Gespeichert.",
|
||||
"error": "Das hat nicht geklappt. Nimm ein JPEG, PNG oder HEIC bis 15 MB.",
|
||||
"chosen": "Gewählt: {name}"
|
||||
},
|
||||
"mail": {
|
||||
"title": "Anmelden per Mail",
|
||||
"intro": "Trag deine Adresse ein. Nach der Bestätigung kannst du dich auf jedem Gerät mit einem Link aus der Mail anmelden. Neue Geräte und Passkeys gehen so nicht.",
|
||||
"label": "Deine Mailadresse",
|
||||
"save": "Bestätigung schicken",
|
||||
"verified": "Bestätigt: {email}",
|
||||
"pending": "Wartet auf Bestätigung: {email}. Schau in dein Postfach.",
|
||||
"remove": "Adresse entfernen",
|
||||
"locked": "Du bist per Mail-Link angemeldet. Adresse, Geräte und Einladungen änderst du mit deinem Passkey.",
|
||||
"sendingTitle": "Mails verschicken",
|
||||
"sendingReady": "Eingerichtet: {from}",
|
||||
"sendingNotReady": "Noch nicht eingerichtet",
|
||||
"sendingSummary": "Für Links zum Anmelden. Standard ist Resend."
|
||||
},
|
||||
"mailSettings": {
|
||||
"title": "Mails verschicken",
|
||||
"intro": "foodplanhero schickt Links zum Anmelden über deinen Zugang bei Resend. Der Schlüssel liegt verschlüsselt auf der Box.",
|
||||
"host": "Server",
|
||||
"port": "Port",
|
||||
"secure": "Verschlüsselt ab Verbindung (Port 465)",
|
||||
"username": "Benutzer",
|
||||
"password": "API-Schlüssel",
|
||||
"passwordSaved": "Ein Schlüssel ist gespeichert. Leer lassen, damit er bleibt.",
|
||||
"fromAddress": "Absender",
|
||||
"fromName": "Name des Absenders",
|
||||
"save": "Speichern",
|
||||
"saved": "Gespeichert.",
|
||||
"remove": "Einstellung entfernen",
|
||||
"testTo": "Testmail an",
|
||||
"test": "Testmail schicken",
|
||||
"testSent": "Die Testmail ist unterwegs. Schau in dein Postfach.",
|
||||
"testFailed": "Das hat nicht geklappt: {detail}",
|
||||
"stepsTitle": "So richtest du Resend ein",
|
||||
"step1": "Konto bei resend.com anlegen.",
|
||||
"step2": "Unter Domains „foodplanhero.de“ hinzufügen, Region EU. Liegt die Domain bei Cloudflare, setzt „Auto configure“ die DNS-Einträge.",
|
||||
"step3": "Unter API Keys einen Schlüssel mit „Sending access“ für diese Domain anlegen und hier eintragen.",
|
||||
"step4": "Speichern, Testmail schicken."
|
||||
}
|
||||
},
|
||||
"nav": {
|
||||
@@ -317,7 +377,7 @@
|
||||
"remove": "Entfernen",
|
||||
"removed": "„{title}“ ist aus dem Pool entfernt.",
|
||||
"undo": "Rückgängig",
|
||||
"photo": "Foto aufnehmen",
|
||||
"photo": "Foto hinzufügen",
|
||||
"photoError": "Das Foto ließ sich nicht lesen. Nimm ein JPEG, PNG oder HEIC bis 15 MB.",
|
||||
"stepTimer": "{n} Min.",
|
||||
"source": "Quelle",
|
||||
@@ -325,7 +385,10 @@
|
||||
"stepTimerProduct": "{n} Min. laut Packung ({product})",
|
||||
"photoAdd": "Foto dazu ({n} von {max})",
|
||||
"photoFull": "5 Fotos sind das Maximum",
|
||||
"present": "Präsentieren"
|
||||
"present": "Präsentieren",
|
||||
"inTrial": "Steht unter „Ausprobieren“, noch nicht im Pool. Dort zieht es der Joker „Etwas Neues“.",
|
||||
"inTrialLink": "Zu „Ausprobieren“",
|
||||
"toPool": "In den Pool"
|
||||
},
|
||||
"form": {
|
||||
"newTitle": "Neues Gericht",
|
||||
@@ -422,9 +485,9 @@
|
||||
"addPhotoText": "Die AI liest Zutaten und Schritte von der Seite ab.",
|
||||
"photo": {
|
||||
"title": "Kochbuch fotografieren",
|
||||
"choose": "Seite fotografieren",
|
||||
"choose": "Seite fotografieren oder wählen",
|
||||
"chosen": "{n, plural, one {1 Foto gewählt} other {# Fotos gewählt}}",
|
||||
"chooseHint": "Eine Rezeptseite, höchstens zwei Fotos. Das Foto wird nicht gespeichert.",
|
||||
"chooseHint": "Eine Rezeptseite, höchstens zwei Fotos – neu aufgenommen oder aus der Mediathek. Das Foto wird nicht gespeichert.",
|
||||
"read": "Rezept lesen",
|
||||
"reading": "Die AI liest …",
|
||||
"readingHint": "Das kann eine Minute dauern.",
|
||||
@@ -1033,5 +1096,25 @@
|
||||
"jar": "{n, plural, one {Glas} other {Gläser}}",
|
||||
"pack": "{n, plural, one {Packung} other {Packungen}}",
|
||||
"bunch": "{n, plural, one {Bund} other {Bund}}"
|
||||
},
|
||||
"mail": {
|
||||
"login": {
|
||||
"subject": "Dein Link zu foodplanhero",
|
||||
"lead": "Tippe auf den Knopf, um dich bei foodplanhero anzumelden. Der Link gilt 15 Minuten und nur einmal.",
|
||||
"button": "Anmelden",
|
||||
"note": "Nicht angefordert? Dann ignoriere diese Mail. Ohne den Link kommt niemand hinein."
|
||||
},
|
||||
"verify": {
|
||||
"subject": "Bitte bestätige deine Adresse",
|
||||
"lead": "Bestätige diese Adresse für foodplanhero. Danach kannst du dich mit einem Link aus der Mail anmelden. Der Link gilt 24 Stunden.",
|
||||
"button": "Adresse bestätigen",
|
||||
"note": "Nicht angefordert? Dann ignoriere diese Mail."
|
||||
},
|
||||
"test": {
|
||||
"subject": "Testmail von foodplanhero",
|
||||
"lead": "Wenn du das liest, kann foodplanhero Mails verschicken.",
|
||||
"button": "foodplanhero öffnen",
|
||||
"note": "Diese Mail kam über die Einstellung unter Mehr › Mails verschicken."
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -49,7 +49,11 @@
|
||||
"submit": "Sign in with passkey",
|
||||
"noPasskey": "No passkey on this device yet? Ask someone in your household for a link under More › Add device.",
|
||||
"lost": "Lost access?",
|
||||
"kids": "Children sign in here"
|
||||
"kids": "Children sign in here",
|
||||
"mailToggle": "Rather get a link by mail?",
|
||||
"mailLabel": "Your email address",
|
||||
"mailSubmit": "Send link",
|
||||
"mailSent": "If the address is confirmed with us, a mail is on its way. The link is valid for 15 minutes."
|
||||
},
|
||||
"invite": {
|
||||
"title": "Invitation to {household}",
|
||||
@@ -75,7 +79,12 @@
|
||||
"forbidden": "Only admins can do this.",
|
||||
"unknown": "That didn't work. Please try again.",
|
||||
"lastPasskey": "This is your last passkey. Add another device first.",
|
||||
"noBackup": "There is no backup."
|
||||
"noBackup": "There is no backup.",
|
||||
"mailSession": "Not possible when signed in with a mail link. Use your passkey for this.",
|
||||
"linkExpired": "This link is no longer valid.",
|
||||
"emailTaken": "This address already belongs to someone else.",
|
||||
"mailNotConfigured": "The household does not send mail yet. An admin sets this up under More › Sending mail.",
|
||||
"mailFailed": "The mail could not be sent. Please try again later."
|
||||
},
|
||||
"recovery": {
|
||||
"title": "Restore access",
|
||||
@@ -92,6 +101,19 @@
|
||||
"submit": "Restore backup",
|
||||
"otherOrigin": "The backup belongs to the address {origin}. Open the app there, otherwise the passkeys won't match.",
|
||||
"or": "Or start fresh"
|
||||
},
|
||||
"mailLink": {
|
||||
"loginTitle": "Sign in to foodplanhero",
|
||||
"loginIntro": "Tap Sign in and you're in.",
|
||||
"loginSubmit": "Sign in",
|
||||
"verifyTitle": "Confirm your address",
|
||||
"verifyIntro": "After that you can also sign in with a link from your mail.",
|
||||
"verifySubmit": "Confirm",
|
||||
"verified": "Your address is confirmed.",
|
||||
"toMore": "Continue",
|
||||
"expiredTitle": "This link is no longer valid",
|
||||
"expiredIntro": "Mail links work once and only for a short time. Just request a new one.",
|
||||
"back": "To sign in"
|
||||
}
|
||||
},
|
||||
"more": {
|
||||
@@ -249,6 +271,44 @@
|
||||
"saved": "Saved.",
|
||||
"error": "That did not work. Use a JPEG, PNG or HEIC up to 15 MB.",
|
||||
"chosen": "Chosen: {name}"
|
||||
},
|
||||
"mail": {
|
||||
"title": "Sign in by mail",
|
||||
"intro": "Add your address. Once confirmed, you can sign in on any device with a link from your mail. New devices and passkeys can't be added this way.",
|
||||
"label": "Your email address",
|
||||
"save": "Send confirmation",
|
||||
"verified": "Confirmed: {email}",
|
||||
"pending": "Waiting for confirmation: {email}. Check your inbox.",
|
||||
"remove": "Remove address",
|
||||
"locked": "You signed in with a mail link. Change your address, devices and invitations with your passkey.",
|
||||
"sendingTitle": "Sending mail",
|
||||
"sendingReady": "Set up: {from}",
|
||||
"sendingNotReady": "Not set up yet",
|
||||
"sendingSummary": "For sign-in links. Resend is the default."
|
||||
},
|
||||
"mailSettings": {
|
||||
"title": "Sending mail",
|
||||
"intro": "foodplanhero sends sign-in links through your Resend account. The key is stored encrypted on the box.",
|
||||
"host": "Server",
|
||||
"port": "Port",
|
||||
"secure": "Encrypted from the start (port 465)",
|
||||
"username": "User",
|
||||
"password": "API key",
|
||||
"passwordSaved": "A key is saved. Leave empty to keep it.",
|
||||
"fromAddress": "Sender",
|
||||
"fromName": "Sender name",
|
||||
"save": "Save",
|
||||
"saved": "Saved.",
|
||||
"remove": "Remove setting",
|
||||
"testTo": "Test mail to",
|
||||
"test": "Send test mail",
|
||||
"testSent": "The test mail is on its way. Check your inbox.",
|
||||
"testFailed": "That didn't work: {detail}",
|
||||
"stepsTitle": "How to set up Resend",
|
||||
"step1": "Create an account at resend.com.",
|
||||
"step2": "Under Domains, add “foodplanhero.de”, region EU. If the domain is on Cloudflare, “Auto configure” sets the DNS records.",
|
||||
"step3": "Under API Keys, create a key with “Sending access” for this domain and enter it here.",
|
||||
"step4": "Save, send a test mail."
|
||||
}
|
||||
},
|
||||
"nav": {
|
||||
@@ -317,7 +377,7 @@
|
||||
"remove": "Remove",
|
||||
"removed": "\"{title}\" was removed from the pool.",
|
||||
"undo": "Undo",
|
||||
"photo": "Take a photo",
|
||||
"photo": "Add photo",
|
||||
"photoError": "The photo couldn't be read. Use a JPEG, PNG or HEIC up to 15 MB.",
|
||||
"stepTimer": "{n} min",
|
||||
"source": "Source",
|
||||
@@ -325,7 +385,10 @@
|
||||
"stepTimerProduct": "{n} min per pack ({product})",
|
||||
"photoAdd": "Add photo ({n} of {max})",
|
||||
"photoFull": "5 photos is the maximum",
|
||||
"present": "Present"
|
||||
"present": "Present",
|
||||
"inTrial": "Listed under “To try”, not yet in the pool. The joker “Something new” picks from there.",
|
||||
"inTrialLink": "Go to “To try”",
|
||||
"toPool": "Move to pool"
|
||||
},
|
||||
"form": {
|
||||
"newTitle": "New dish",
|
||||
@@ -422,9 +485,9 @@
|
||||
"addPhotoText": "The AI reads ingredients and steps from the page.",
|
||||
"photo": {
|
||||
"title": "Photograph a cookbook",
|
||||
"choose": "Take a photo of the page",
|
||||
"choose": "Take or choose a photo of the page",
|
||||
"chosen": "{n, plural, one {1 photo chosen} other {# photos chosen}}",
|
||||
"chooseHint": "One recipe page, at most two photos. The photo is not kept.",
|
||||
"chooseHint": "One recipe page, at most two photos – new or from your library. The photo is not kept.",
|
||||
"read": "Read recipe",
|
||||
"reading": "The AI is reading …",
|
||||
"readingHint": "This can take a minute.",
|
||||
@@ -1033,5 +1096,25 @@
|
||||
"jar": "{n, plural, one {jar} other {jars}}",
|
||||
"pack": "{n, plural, one {pack} other {packs}}",
|
||||
"bunch": "{n, plural, one {bunch} other {bunches}}"
|
||||
},
|
||||
"mail": {
|
||||
"login": {
|
||||
"subject": "Your link to foodplanhero",
|
||||
"lead": "Tap the button to sign in to foodplanhero. The link is valid for 15 minutes and works once.",
|
||||
"button": "Sign in",
|
||||
"note": "Didn't ask for this? Just ignore this mail. Nobody gets in without the link."
|
||||
},
|
||||
"verify": {
|
||||
"subject": "Please confirm your address",
|
||||
"lead": "Confirm this address for foodplanhero. After that you can sign in with a link from your mail. The link is valid for 24 hours.",
|
||||
"button": "Confirm address",
|
||||
"note": "Didn't ask for this? Just ignore this mail."
|
||||
},
|
||||
"test": {
|
||||
"subject": "Test mail from foodplanhero",
|
||||
"lead": "If you can read this, foodplanhero can send mail.",
|
||||
"button": "Open foodplanhero",
|
||||
"note": "This mail was sent with the setting under More › Sending mail."
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -49,7 +49,11 @@
|
||||
"submit": "Sign in with passkey",
|
||||
"noPasskey": "No passkey on this device yet? Ask someone in your household for a link under More › Add device.",
|
||||
"lost": "Lost access?",
|
||||
"kids": "Children sign in here"
|
||||
"kids": "Children sign in here",
|
||||
"mailToggle": "¿Prefieres un enlace por correo?",
|
||||
"mailLabel": "Tu correo electrónico",
|
||||
"mailSubmit": "Enviar enlace",
|
||||
"mailSent": "Si la dirección está confirmada, llegará un correo. El enlace vale 15 minutos."
|
||||
},
|
||||
"invite": {
|
||||
"title": "Invitation to {household}",
|
||||
@@ -75,7 +79,12 @@
|
||||
"forbidden": "Only admins can do this.",
|
||||
"unknown": "That didn't work. Please try again.",
|
||||
"lastPasskey": "This is your last passkey. Add another device first.",
|
||||
"noBackup": "There is no backup."
|
||||
"noBackup": "There is no backup.",
|
||||
"mailSession": "No es posible con un inicio de sesión por enlace. Usa tu llave de acceso.",
|
||||
"linkExpired": "Este enlace ya no es válido.",
|
||||
"emailTaken": "Esta dirección ya pertenece a otra persona.",
|
||||
"mailNotConfigured": "El hogar aún no envía correos. Un admin lo configura en Más › Envío de correos.",
|
||||
"mailFailed": "No se pudo enviar el correo. Inténtalo más tarde."
|
||||
},
|
||||
"recovery": {
|
||||
"title": "Restore access",
|
||||
@@ -92,6 +101,19 @@
|
||||
"submit": "Restore backup",
|
||||
"otherOrigin": "The backup belongs to the address {origin}. Open the app there, otherwise the passkeys won't match.",
|
||||
"or": "Or start fresh"
|
||||
},
|
||||
"mailLink": {
|
||||
"loginTitle": "Entrar en foodplanhero",
|
||||
"loginIntro": "Toca Entrar y listo.",
|
||||
"loginSubmit": "Entrar",
|
||||
"verifyTitle": "Confirmar dirección",
|
||||
"verifyIntro": "Después podrás entrar también con un enlace por correo.",
|
||||
"verifySubmit": "Confirmar",
|
||||
"verified": "Tu dirección está confirmada.",
|
||||
"toMore": "Continuar",
|
||||
"expiredTitle": "Este enlace ya no es válido",
|
||||
"expiredIntro": "Los enlaces por correo valen una vez y poco tiempo. Pide uno nuevo.",
|
||||
"back": "Ir a entrar"
|
||||
}
|
||||
},
|
||||
"more": {
|
||||
@@ -249,6 +271,44 @@
|
||||
"saved": "Saved.",
|
||||
"error": "That did not work. Use a JPEG, PNG or HEIC up to 15 MB.",
|
||||
"chosen": "Chosen: {name}"
|
||||
},
|
||||
"mail": {
|
||||
"title": "Entrar por correo",
|
||||
"intro": "Añade tu dirección. Una vez confirmada, podrás entrar en cualquier dispositivo con un enlace por correo. Así no se añaden dispositivos ni llaves de acceso.",
|
||||
"label": "Tu correo electrónico",
|
||||
"save": "Enviar confirmación",
|
||||
"verified": "Confirmada: {email}",
|
||||
"pending": "Pendiente de confirmar: {email}. Mira tu bandeja.",
|
||||
"remove": "Quitar dirección",
|
||||
"locked": "Has entrado con un enlace por correo. Dirección, dispositivos e invitaciones se cambian con tu llave de acceso.",
|
||||
"sendingTitle": "Envío de correos",
|
||||
"sendingReady": "Configurado: {from}",
|
||||
"sendingNotReady": "Aún sin configurar",
|
||||
"sendingSummary": "Para enlaces de acceso. Resend por defecto."
|
||||
},
|
||||
"mailSettings": {
|
||||
"title": "Envío de correos",
|
||||
"intro": "foodplanhero envía los enlaces de acceso con tu cuenta de Resend. La clave se guarda cifrada en la box.",
|
||||
"host": "Servidor",
|
||||
"port": "Puerto",
|
||||
"secure": "Cifrado desde el inicio (puerto 465)",
|
||||
"username": "Usuario",
|
||||
"password": "Clave API",
|
||||
"passwordSaved": "Hay una clave guardada. Déjalo vacío para conservarla.",
|
||||
"fromAddress": "Remitente",
|
||||
"fromName": "Nombre del remitente",
|
||||
"save": "Guardar",
|
||||
"saved": "Guardado.",
|
||||
"remove": "Quitar ajuste",
|
||||
"testTo": "Correo de prueba a",
|
||||
"test": "Enviar correo de prueba",
|
||||
"testSent": "El correo de prueba va en camino. Mira tu bandeja.",
|
||||
"testFailed": "No funcionó: {detail}",
|
||||
"stepsTitle": "Cómo configurar Resend",
|
||||
"step1": "Crea una cuenta en resend.com.",
|
||||
"step2": "En Domains añade «foodplanhero.de», región EU. Si el dominio está en Cloudflare, «Auto configure» crea los registros DNS.",
|
||||
"step3": "En API Keys crea una clave con «Sending access» para este dominio e introdúcela aquí.",
|
||||
"step4": "Guarda y envía un correo de prueba."
|
||||
}
|
||||
},
|
||||
"nav": {
|
||||
@@ -317,7 +377,7 @@
|
||||
"remove": "Remove",
|
||||
"removed": "\"{title}\" was removed from the pool.",
|
||||
"undo": "Undo",
|
||||
"photo": "Take a photo",
|
||||
"photo": "Add photo",
|
||||
"photoError": "The photo couldn't be read. Use a JPEG, PNG or HEIC up to 15 MB.",
|
||||
"stepTimer": "{n} min",
|
||||
"source": "Source",
|
||||
@@ -325,7 +385,10 @@
|
||||
"stepTimerProduct": "{n} min según el paquete ({product})",
|
||||
"photoAdd": "Añadir foto ({n} de {max})",
|
||||
"photoFull": "5 fotos es el máximo",
|
||||
"present": "Present"
|
||||
"present": "Present",
|
||||
"inTrial": "Listed under “To try”, not yet in the pool. The joker “Something new” picks from there.",
|
||||
"inTrialLink": "Go to “To try”",
|
||||
"toPool": "Move to pool"
|
||||
},
|
||||
"form": {
|
||||
"newTitle": "New dish",
|
||||
@@ -422,9 +485,9 @@
|
||||
"addPhotoText": "The AI reads ingredients and steps from the page.",
|
||||
"photo": {
|
||||
"title": "Photograph a cookbook",
|
||||
"choose": "Take a photo of the page",
|
||||
"choose": "Take or choose a photo of the page",
|
||||
"chosen": "{n, plural, one {1 photo chosen} other {# photos chosen}}",
|
||||
"chooseHint": "One recipe page, at most two photos. The photo is not kept.",
|
||||
"chooseHint": "One recipe page, at most two photos – new or from your library. The photo is not kept.",
|
||||
"read": "Read recipe",
|
||||
"reading": "The AI is reading …",
|
||||
"readingHint": "This can take a minute.",
|
||||
@@ -1033,5 +1096,25 @@
|
||||
"jar": "{n, plural, one {tarro} other {tarros}}",
|
||||
"pack": "{n, plural, one {paquete} other {paquetes}}",
|
||||
"bunch": "{n, plural, one {manojo} other {manojos}}"
|
||||
},
|
||||
"mail": {
|
||||
"login": {
|
||||
"subject": "Tu enlace a foodplanhero",
|
||||
"lead": "Toca el botón para entrar en foodplanhero. El enlace vale 15 minutos y una sola vez.",
|
||||
"button": "Entrar",
|
||||
"note": "¿No lo pediste? Ignora este correo. Sin el enlace nadie entra."
|
||||
},
|
||||
"verify": {
|
||||
"subject": "Confirma tu dirección",
|
||||
"lead": "Confirma esta dirección para foodplanhero. Después podrás entrar con un enlace por correo. El enlace vale 24 horas.",
|
||||
"button": "Confirmar dirección",
|
||||
"note": "¿No lo pediste? Ignora este correo."
|
||||
},
|
||||
"test": {
|
||||
"subject": "Correo de prueba de foodplanhero",
|
||||
"lead": "Si lees esto, foodplanhero puede enviar correos.",
|
||||
"button": "Abrir foodplanhero",
|
||||
"note": "Este correo usó el ajuste de Más › Envío de correos."
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -49,7 +49,11 @@
|
||||
"submit": "Sign in with passkey",
|
||||
"noPasskey": "No passkey on this device yet? Ask someone in your household for a link under More › Add device.",
|
||||
"lost": "Lost access?",
|
||||
"kids": "Children sign in here"
|
||||
"kids": "Children sign in here",
|
||||
"mailToggle": "Plutôt un lien par e-mail ?",
|
||||
"mailLabel": "Ton adresse e-mail",
|
||||
"mailSubmit": "Envoyer le lien",
|
||||
"mailSent": "Si l’adresse est confirmée chez nous, un e-mail arrive. Le lien est valable 15 minutes."
|
||||
},
|
||||
"invite": {
|
||||
"title": "Invitation to {household}",
|
||||
@@ -75,7 +79,12 @@
|
||||
"forbidden": "Only admins can do this.",
|
||||
"unknown": "That didn't work. Please try again.",
|
||||
"lastPasskey": "This is your last passkey. Add another device first.",
|
||||
"noBackup": "There is no backup."
|
||||
"noBackup": "There is no backup.",
|
||||
"mailSession": "Impossible avec une connexion par lien e-mail. Utilise ta clé d’accès.",
|
||||
"linkExpired": "Ce lien n’est plus valable.",
|
||||
"emailTaken": "Cette adresse appartient déjà à quelqu’un d’autre.",
|
||||
"mailNotConfigured": "Le foyer n’envoie pas encore d’e-mails. Un admin le configure sous Plus › Envoi d’e-mails.",
|
||||
"mailFailed": "L’e-mail n’a pas pu être envoyé. Réessaie plus tard."
|
||||
},
|
||||
"recovery": {
|
||||
"title": "Restore access",
|
||||
@@ -92,6 +101,19 @@
|
||||
"submit": "Restore backup",
|
||||
"otherOrigin": "The backup belongs to the address {origin}. Open the app there, otherwise the passkeys won't match.",
|
||||
"or": "Or start fresh"
|
||||
},
|
||||
"mailLink": {
|
||||
"loginTitle": "Se connecter à foodplanhero",
|
||||
"loginIntro": "Touche Se connecter, et c’est parti.",
|
||||
"loginSubmit": "Se connecter",
|
||||
"verifyTitle": "Confirmer l’adresse",
|
||||
"verifyIntro": "Ensuite, tu pourras aussi te connecter avec un lien par e-mail.",
|
||||
"verifySubmit": "Confirmer",
|
||||
"verified": "Ton adresse est confirmée.",
|
||||
"toMore": "Continuer",
|
||||
"expiredTitle": "Ce lien n’est plus valable",
|
||||
"expiredIntro": "Les liens par e-mail ne servent qu’une fois et peu de temps. Demandes-en un nouveau.",
|
||||
"back": "Vers la connexion"
|
||||
}
|
||||
},
|
||||
"more": {
|
||||
@@ -249,6 +271,44 @@
|
||||
"saved": "Saved.",
|
||||
"error": "That did not work. Use a JPEG, PNG or HEIC up to 15 MB.",
|
||||
"chosen": "Chosen: {name}"
|
||||
},
|
||||
"mail": {
|
||||
"title": "Connexion par e-mail",
|
||||
"intro": "Ajoute ton adresse. Une fois confirmée, tu peux te connecter sur n’importe quel appareil avec un lien par e-mail. Pas de nouveaux appareils ni de clés d’accès de cette façon.",
|
||||
"label": "Ton adresse e-mail",
|
||||
"save": "Envoyer la confirmation",
|
||||
"verified": "Confirmée : {email}",
|
||||
"pending": "En attente de confirmation : {email}. Regarde ta boîte.",
|
||||
"remove": "Retirer l’adresse",
|
||||
"locked": "Tu es connecté·e par lien e-mail. Adresse, appareils et invitations se changent avec ta clé d’accès.",
|
||||
"sendingTitle": "Envoi d’e-mails",
|
||||
"sendingReady": "Configuré : {from}",
|
||||
"sendingNotReady": "Pas encore configuré",
|
||||
"sendingSummary": "Pour les liens de connexion. Resend par défaut."
|
||||
},
|
||||
"mailSettings": {
|
||||
"title": "Envoi d’e-mails",
|
||||
"intro": "foodplanhero envoie les liens de connexion via ton compte Resend. La clé est chiffrée sur la box.",
|
||||
"host": "Serveur",
|
||||
"port": "Port",
|
||||
"secure": "Chiffré dès la connexion (port 465)",
|
||||
"username": "Utilisateur",
|
||||
"password": "Clé API",
|
||||
"passwordSaved": "Une clé est enregistrée. Laisse vide pour la garder.",
|
||||
"fromAddress": "Expéditeur",
|
||||
"fromName": "Nom de l’expéditeur",
|
||||
"save": "Enregistrer",
|
||||
"saved": "Enregistré.",
|
||||
"remove": "Supprimer le réglage",
|
||||
"testTo": "E-mail de test à",
|
||||
"test": "Envoyer un e-mail de test",
|
||||
"testSent": "L’e-mail de test est parti. Regarde ta boîte.",
|
||||
"testFailed": "Ça n’a pas marché : {detail}",
|
||||
"stepsTitle": "Configurer Resend",
|
||||
"step1": "Crée un compte sur resend.com.",
|
||||
"step2": "Sous Domains, ajoute « foodplanhero.de », région EU. Si le domaine est chez Cloudflare, « Auto configure » crée les entrées DNS.",
|
||||
"step3": "Sous API Keys, crée une clé avec « Sending access » pour ce domaine et saisis-la ici.",
|
||||
"step4": "Enregistre, envoie un e-mail de test."
|
||||
}
|
||||
},
|
||||
"nav": {
|
||||
@@ -317,7 +377,7 @@
|
||||
"remove": "Remove",
|
||||
"removed": "\"{title}\" was removed from the pool.",
|
||||
"undo": "Undo",
|
||||
"photo": "Take a photo",
|
||||
"photo": "Add photo",
|
||||
"photoError": "The photo couldn't be read. Use a JPEG, PNG or HEIC up to 15 MB.",
|
||||
"stepTimer": "{n} min",
|
||||
"source": "Source",
|
||||
@@ -325,7 +385,10 @@
|
||||
"stepTimerProduct": "{n} min selon le paquet ({product})",
|
||||
"photoAdd": "Ajouter une photo ({n} sur {max})",
|
||||
"photoFull": "5 photos au maximum",
|
||||
"present": "Present"
|
||||
"present": "Present",
|
||||
"inTrial": "Listed under “To try”, not yet in the pool. The joker “Something new” picks from there.",
|
||||
"inTrialLink": "Go to “To try”",
|
||||
"toPool": "Move to pool"
|
||||
},
|
||||
"form": {
|
||||
"newTitle": "New dish",
|
||||
@@ -422,9 +485,9 @@
|
||||
"addPhotoText": "The AI reads ingredients and steps from the page.",
|
||||
"photo": {
|
||||
"title": "Photograph a cookbook",
|
||||
"choose": "Take a photo of the page",
|
||||
"choose": "Take or choose a photo of the page",
|
||||
"chosen": "{n, plural, one {1 photo chosen} other {# photos chosen}}",
|
||||
"chooseHint": "One recipe page, at most two photos. The photo is not kept.",
|
||||
"chooseHint": "One recipe page, at most two photos – new or from your library. The photo is not kept.",
|
||||
"read": "Read recipe",
|
||||
"reading": "The AI is reading …",
|
||||
"readingHint": "This can take a minute.",
|
||||
@@ -1033,5 +1096,25 @@
|
||||
"jar": "{n, plural, one {bocal} other {bocaux}}",
|
||||
"pack": "{n, plural, one {paquet} other {paquets}}",
|
||||
"bunch": "{n, plural, one {botte} other {bottes}}"
|
||||
},
|
||||
"mail": {
|
||||
"login": {
|
||||
"subject": "Ton lien vers foodplanhero",
|
||||
"lead": "Touche le bouton pour te connecter à foodplanhero. Le lien est valable 15 minutes et une seule fois.",
|
||||
"button": "Se connecter",
|
||||
"note": "Pas demandé ? Ignore cet e-mail. Sans le lien, personne n’entre."
|
||||
},
|
||||
"verify": {
|
||||
"subject": "Confirme ton adresse",
|
||||
"lead": "Confirme cette adresse pour foodplanhero. Ensuite, tu pourras te connecter avec un lien par e-mail. Le lien est valable 24 heures.",
|
||||
"button": "Confirmer l’adresse",
|
||||
"note": "Pas demandé ? Ignore cet e-mail."
|
||||
},
|
||||
"test": {
|
||||
"subject": "E-mail de test de foodplanhero",
|
||||
"lead": "Si tu lis ceci, foodplanhero peut envoyer des e-mails.",
|
||||
"button": "Ouvrir foodplanhero",
|
||||
"note": "Cet e-mail utilise le réglage sous Plus › Envoi d’e-mails."
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,5 +2,5 @@ apiVersion: v2
|
||||
name: lunch
|
||||
description: foodplanhero (Plan. Cook. Smile.) — die Familie entscheidet gemeinsam, was es gibt; aus dem Plan entsteht die Einkaufsliste
|
||||
type: application
|
||||
version: 26.11.39 # YY.M.<n> wie im AImighty-Markt — bei jeder Chart-Änderung erhöhen
|
||||
appVersion: "26.11.39" # MUSS gleich version sein: der Linter prüft es, und der Image-Tag hängt daran
|
||||
version: 26.11.43 # YY.M.<n> wie im AImighty-Markt — bei jeder Chart-Änderung erhöhen
|
||||
appVersion: "26.11.43" # MUSS gleich version sein: der Linter prüft es, und der Image-Tag hängt daran
|
||||
@@ -21,7 +21,7 @@ metadata:
|
||||
title: foodplanhero
|
||||
description: Plan. Cook. Smile. The family decides together what's for dinner — and the shopping list writes itself. Runs entirely on your own box.
|
||||
icon: https://git.aimighty.olares.de/aimighty/bilder/raw/branch/main/lunch/icon.png
|
||||
version: 26.11.39
|
||||
version: 26.11.43
|
||||
categories:
|
||||
- Applications
|
||||
|
||||
@@ -61,7 +61,7 @@ permission:
|
||||
appData: true
|
||||
|
||||
spec:
|
||||
versionName: '26.11.39'
|
||||
versionName: '26.11.43'
|
||||
|
||||
featuredImage: https://git.aimighty.olares.de/aimighty/bilder/raw/branch/main/lunch/icon.png
|
||||
promoteImage:
|
||||
|
||||
|
Before Width: | Height: | Size: 23 KiB After Width: | Height: | Size: 13 KiB |
@@ -0,0 +1,5 @@
|
||||
# Sign in with a link by mail
|
||||
v26.11.40: You can now sign in with a link from your mail as well as with a passkey. Under More, add your address and confirm it through the first link. On the sign-in page, tap "Rather get a link by mail?" and you receive a link that works once and for 15 minutes. A session started from a mail link can only sign in: it cannot add devices or passkeys, create invitations or change the address, so a mailbox alone never gives lasting access. Such sessions last 30 days, and removing the address ends them. An admin sets up sending under More › Sending mail, with Resend as the default. The API key is stored encrypted on the box. The answer to a link request never reveals whether an address exists.
|
||||
|
||||
## Deutsch
|
||||
v26.11.40: Anmelden geht jetzt außer mit dem Passkey auch mit einem Link aus der Mail. Unter Mehr trägst du deine Adresse ein und bestätigst sie über den ersten Link. Auf der Anmeldeseite tippst du „Lieber einen Link per Mail?“ und bekommst einen Link, der einmal und 15 Minuten gilt. Eine Sitzung aus einem Mail-Link kann nur anmelden: Sie kann keine Geräte oder Passkeys hinzufügen, keine Einladungen erstellen und die Adresse nicht ändern, so verschafft das Postfach allein nie dauerhaften Zugang. Solche Sitzungen gelten 30 Tage, und wer die Adresse entfernt, beendet sie. Den Versand richtet ein Admin unter Mehr › Mails verschicken ein, Standard ist Resend. Der API-Schlüssel liegt verschlüsselt auf der Box. Die Antwort auf eine Link-Anfrage verrät nie, ob es eine Adresse gibt.
|
||||
@@ -0,0 +1,5 @@
|
||||
# The bottom bar stays at the bottom, and dishes to try say so
|
||||
v26.11.41: On the iPhone, the bottom bar and the buttons above it (Save, Cancel) could get stuck in the middle of the screen after typing, and stayed there even after scrolling. iOS sometimes keeps calculating the screen as if the keyboard were still open, long after it has closed. foodplanhero now holds the bar at the bottom for as long as that lasts, through touches and scrolling, and lets go as soon as iOS calculates correctly again. The buttons above the bar and the plus button on the dishes page follow the bar. Small movements such as bouncing at the end of a page are left alone. Dishes created from a photo, text or recipe link go to "To try" first, which is what the joker "Something new" picks from. Their page now says so, links to that tab and has a "Move to pool" button; the back arrow leads to "To try".
|
||||
|
||||
## Deutsch
|
||||
v26.11.41: Am iPhone konnten nach dem Tippen die Leiste unten und die Knöpfe darüber (Speichern, Abbrechen) mitten im Bild stehen bleiben, auch nach dem Scrollen. iOS rechnet den Bildschirm manchmal noch lange so, als wäre die Tastatur offen, obwohl sie längst zu ist. foodplanhero hält die Leiste jetzt unten, solange das dauert, auch beim Berühren und Scrollen, und lässt sie los, sobald iOS wieder richtig rechnet. Die Knöpfe über der Leiste und der Plus-Knopf bei den Gerichten gehen mit. Kleine Bewegungen wie das Nachfedern am Seitenende bleiben unberührt. Gerichte aus Foto, Text oder Rezept-Link stehen zuerst unter „Ausprobieren“, daraus zieht der Joker „Etwas Neues“. Ihre Seite sagt das jetzt, führt zu diesem Reiter und hat einen Knopf „In den Pool“; der Pfeil zurück führt zu „Ausprobieren“.
|
||||
@@ -0,0 +1,5 @@
|
||||
# A new icon: chef's hat with a heart
|
||||
v26.11.42: foodplanhero has a new icon: a white chef's hat with a heart, on the familiar coral. It replaces the plate with the leaf on the home screen, in the browser tab and in the market. To see it on the home screen, remove the app there once and add it again.
|
||||
|
||||
## Deutsch
|
||||
v26.11.42: foodplanhero hat ein neues Symbol: eine weiße Kochmütze mit Herz auf dem vertrauten Koralle. Sie ersetzt den Teller mit dem Blatt auf dem Home-Bildschirm, im Browser-Tab und im Markt. Damit das iPhone es zeigt, die App vom Home-Bildschirm einmal entfernen und neu hinzufügen.
|
||||
@@ -0,0 +1,5 @@
|
||||
# Photos from your library
|
||||
v26.11.43: Photos for a dish no longer have to be taken with the camera. Tapping "Add photo" on the iPhone now offers the photo library, the camera and files, and you can pick several photos from the library at once, up to five per dish. The same works for photos of a cookbook page and for the photo after cooking.
|
||||
|
||||
## Deutsch
|
||||
v26.11.43: Fotos für ein Gericht müssen nicht mehr mit der Kamera aufgenommen werden. „Foto hinzufügen“ bietet am iPhone jetzt Fotomediathek, Kamera und Dateien an, und aus der Mediathek lassen sich mehrere Fotos auf einmal wählen, bis zu fünf je Gericht. Genauso geht es beim Foto einer Kochbuchseite und beim Foto nach dem Kochen.
|
||||
@@ -20,6 +20,7 @@
|
||||
"lucide-react": "^1.70.0",
|
||||
"next": "15.5.29",
|
||||
"next-intl": "^4.14.9",
|
||||
"nodemailer": "6.9.16",
|
||||
"pg": "^8.23.1",
|
||||
"react": "19.2.0",
|
||||
"react-dom": "19.2.0",
|
||||
@@ -34,6 +35,7 @@
|
||||
"@playwright/test": "1.63.0",
|
||||
"@tailwindcss/postcss": "^4.3.5",
|
||||
"@types/node": "^22.20.5",
|
||||
"@types/nodemailer": "6.4.17",
|
||||
"@types/pg": "^8.23.1",
|
||||
"@types/react": "^19.3.0",
|
||||
"@types/react-dom": "^19.3.0",
|
||||
@@ -2994,6 +2996,16 @@
|
||||
"undici-types": "~6.21.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@types/nodemailer": {
|
||||
"version": "6.4.17",
|
||||
"resolved": "https://registry.npmjs.org/@types/nodemailer/-/nodemailer-6.4.17.tgz",
|
||||
"integrity": "sha512-I9CCaIp6DTldEg7vyUTZi8+9Vo0hi1/T8gv3C89yk1rSAAzoKQ8H8ki/jBYJSFoH/BisgLP8tkZMlQ91CIquww==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@types/node": "*"
|
||||
}
|
||||
},
|
||||
"node_modules/@types/pg": {
|
||||
"version": "8.23.1",
|
||||
"resolved": "https://registry.npmjs.org/@types/pg/-/pg-8.23.1.tgz",
|
||||
@@ -4212,6 +4224,15 @@
|
||||
"node": ">=18"
|
||||
}
|
||||
},
|
||||
"node_modules/nodemailer": {
|
||||
"version": "6.9.16",
|
||||
"resolved": "https://registry.npmjs.org/nodemailer/-/nodemailer-6.9.16.tgz",
|
||||
"integrity": "sha512-psAuZdTIRN08HKVd/E8ObdV6NO7NTBY3KsC30F7M4H1OnmLCUNaS56FpYxyb26zWLSyYF9Ozch9KYHhHegsiOQ==",
|
||||
"license": "MIT-0",
|
||||
"engines": {
|
||||
"node": ">=6.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/path-scurry": {
|
||||
"version": "2.0.2",
|
||||
"resolved": "https://registry.npmjs.org/path-scurry/-/path-scurry-2.0.2.tgz",
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
"lucide-react": "^1.70.0",
|
||||
"next": "15.5.29",
|
||||
"next-intl": "^4.14.9",
|
||||
"nodemailer": "6.9.16",
|
||||
"pg": "^8.23.1",
|
||||
"react": "19.2.0",
|
||||
"react-dom": "19.2.0",
|
||||
@@ -38,6 +39,7 @@
|
||||
"@playwright/test": "1.63.0",
|
||||
"@tailwindcss/postcss": "^4.3.5",
|
||||
"@types/node": "^22.20.5",
|
||||
"@types/nodemailer": "6.4.17",
|
||||
"@types/pg": "^8.23.1",
|
||||
"@types/react": "^19.3.0",
|
||||
"@types/react-dom": "^19.3.0",
|
||||
|
||||
@@ -81,10 +81,17 @@ export default defineConfig({
|
||||
dependencies: ["pwa"],
|
||||
use: { ...iphone, storageState: "e2e/.auth/kai.json" },
|
||||
},
|
||||
{
|
||||
// Anmelden per Mail-Link (26.11.40): braucht MAIL_TEST_DIR am Server ($LUNCH_DATA/mails).
|
||||
name: "mail",
|
||||
testMatch: /mail\.spec\.ts/,
|
||||
dependencies: ["leiste"],
|
||||
use: { ...iphone, storageState: "e2e/.auth/kai.json" },
|
||||
},
|
||||
{
|
||||
name: "iphone-hell",
|
||||
testMatch: /rundgang\.spec\.ts/,
|
||||
dependencies: ["leiste"],
|
||||
dependencies: ["mail"],
|
||||
use: { ...iphone, colorScheme: "light", storageState: "e2e/.auth/kai.json" },
|
||||
},
|
||||
{
|
||||
|
||||
|
Before Width: | Height: | Size: 5.4 KiB After Width: | Height: | Size: 2.8 KiB |
|
Before Width: | Height: | Size: 8.7 KiB After Width: | Height: | Size: 4.8 KiB |
|
Before Width: | Height: | Size: 17 KiB After Width: | Height: | Size: 8.4 KiB |
|
Before Width: | Height: | Size: 23 KiB After Width: | Height: | Size: 13 KiB |
@@ -1,15 +1,8 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512">
|
||||
<rect width="512" height="512" rx="112" fill="#f39380"/>
|
||||
<!-- Teller -->
|
||||
<circle cx="256" cy="292" r="142" fill="#fefdff"/>
|
||||
<circle cx="256" cy="292" r="98" fill="none" stroke="#e7e1f6" stroke-width="14"/>
|
||||
<!-- Dampf -->
|
||||
<g fill="none" stroke="#fefdff" stroke-width="18" stroke-linecap="round">
|
||||
<path d="M206 78c-16 18 16 30 0 48"/>
|
||||
<path d="M256 64c-16 20 16 34 0 54"/>
|
||||
<path d="M306 78c-16 18 16 30 0 48"/>
|
||||
</g>
|
||||
<!-- Salbeiblatt -->
|
||||
<path d="M206 316c20-62 86-82 116-72-6 52-58 98-116 72z" fill="#7761b0"/>
|
||||
<path d="M214 312c30-24 58-42 96-62" stroke="#fefdff" stroke-width="7" stroke-linecap="round" fill="none"/>
|
||||
</svg>
|
||||
<!-- foodplanhero (Kai, 7.11.2026, 26.11.42): Kochmütze mit Herz, für Maike. Koralle wie bisher. --><rect width="512" height="512" rx="112" fill="#f39380"/><g>
|
||||
<circle cx="178" cy="214" r="70" fill="#fefdff"/>
|
||||
<circle cx="256" cy="176" r="86" fill="#fefdff"/>
|
||||
<circle cx="334" cy="214" r="70" fill="#fefdff"/>
|
||||
<rect x="158" y="210" width="196" height="132" fill="#fefdff"/>
|
||||
<rect x="150" y="350" width="212" height="56" rx="20" fill="#fefdff"/>
|
||||
</g><path d="M256 318 C230 298 202 276 202 250 C202 230 217 218 234 218 C245 218 252 224 256 233 C260 224 267 218 278 218 C295 218 310 230 310 250 C310 276 282 298 256 318 Z" fill="#f39380"/></svg>
|
||||
|
Before Width: | Height: | Size: 719 B After Width: | Height: | Size: 720 B |
@@ -8,6 +8,7 @@ export const SEEDED_TABLES = [
|
||||
"dish_ingredients", "dish_steps", "dish_translations", "rounds", "wishes", "slots", "shopping_items",
|
||||
"pantry_staples", "receipts", "receipt_lines", "ingredient_aliases", "price_points", "ratings", "kudos",
|
||||
"helper_points", "achievements", "household_ai", "kid_devices", "dish_photos", "ingredients", "household_products", "household_pack_sizes",
|
||||
"household_mail", "mail_tokens",
|
||||
];
|
||||
|
||||
/** Eine globale Zutat, wie sie eine Seed-Migration anlegt. */
|
||||
@@ -90,6 +91,8 @@ export async function seedHousehold(client: pg.Client | pg.PoolClient, h: string
|
||||
await q("insert into household_products (household_id, ingredient_id, product) values ($1, $2, 'Barilla Nr. 5')", [h, own]);
|
||||
await q("insert into household_pack_sizes (household_id, ingredient_id, pack_size) select $1, id, 500 from ingredients where key = 'chopped_tomatoes'", [h]);
|
||||
await q("insert into household_ai (household_id, endpoint, vision_model, updated_by) values ($1, 'http://llm.test/v1', 'vision', $2)", [h, member]);
|
||||
await q("insert into household_mail (household_id, host, port, username, from_address) values ($1, 'smtp.test', 465, 'resend', 'hallo@test.example')", [h]);
|
||||
await q("insert into mail_tokens (household_id, member_id, purpose, email, token_hash, expires_at) values ($1, $2, 'verify', $3, sha256(convert_to($3, 'utf8')), now() + interval '1 hour')", [h, member, `kai-${h}@test.example`]);
|
||||
await q("commit");
|
||||
return { dish, member };
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { keyboardGap } from "@/lib/use-keyboard-nav";
|
||||
import { keyboardGap, STUCK_MIN, stuckShift } from "@/lib/use-keyboard-nav";
|
||||
|
||||
// Wann die untere Leiste nach dem Tippen nachgeschoben wird (26.11.32): nur bei einer
|
||||
// Lücke, wie sie eine eben geschlossene Tastatur hinterlässt — nie für Adressleiste,
|
||||
@@ -18,3 +18,13 @@ describe("keyboard gap", () => {
|
||||
expect(keyboardGap(vv(5000), 520)).toBe(0);
|
||||
});
|
||||
});
|
||||
|
||||
describe("stuck keyboard (26.11.41)", () => {
|
||||
it("in the first second every gap counts, afterwards only a keyboard-sized one", () => {
|
||||
expect(stuckShift(80, true)).toBe(80);
|
||||
expect(stuckShift(80, false)).toBe(0);
|
||||
expect(stuckShift(STUCK_MIN, false)).toBe(STUCK_MIN);
|
||||
expect(stuckShift(336, false)).toBe(336);
|
||||
expect(stuckShift(0, false)).toBe(0);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,124 @@
|
||||
import { randomUUID } from "node:crypto";
|
||||
import { mkdtemp, readdir, readFile } from "node:fs/promises";
|
||||
import { tmpdir } from "node:os";
|
||||
import path from "node:path";
|
||||
import pg from "pg";
|
||||
import { afterAll, beforeAll, describe, expect, it, vi } from "vitest";
|
||||
import { seedHousehold } from "./fixture";
|
||||
|
||||
vi.mock("server-only", () => ({}));
|
||||
vi.mock("next-intl/server", () => ({ getTranslations: async () => (key: string) => `[${key}]` }));
|
||||
|
||||
// Anmelden per Link aus der Mail (26.11.40): Ein Link gilt einmal und kurz, nur für
|
||||
// eine bestätigte Adresse einer erwachsenen Person; Bestätigen setzt die Adresse.
|
||||
// Der Schlüssel des Mailwegs liegt verschlüsselt; ohne Einstellung kein Versand.
|
||||
const url = process.env.TEST_DATABASE_URL;
|
||||
|
||||
describe.skipIf(!url)("mail sign-in", () => {
|
||||
const client = new pg.Client({ connectionString: url });
|
||||
const h = randomUUID();
|
||||
let member = "";
|
||||
let child = "";
|
||||
let ml: typeof import("@/lib/auth/mail-login");
|
||||
let mail: typeof import("@/lib/mail");
|
||||
let db: typeof import("@/lib/db");
|
||||
let vault: typeof import("@/lib/vault");
|
||||
const email = `maike-${h.slice(0, 8)}@test.example`;
|
||||
|
||||
beforeAll(async () => {
|
||||
process.env.DATABASE_URL = url;
|
||||
process.env.APP_DATA_DIR = await mkdtemp(path.join(tmpdir(), "lunch-mail-"));
|
||||
process.env.MAIL_TEST_DIR = path.join(process.env.APP_DATA_DIR, "mails");
|
||||
await client.connect();
|
||||
const ingredient = (await client.query("select id from ingredients limit 1")).rows[0].id;
|
||||
member = (await seedHousehold(client, h, ingredient)).member;
|
||||
db = await import("@/lib/db");
|
||||
ml = await import("@/lib/auth/mail-login");
|
||||
mail = await import("@/lib/mail");
|
||||
vault = await import("@/lib/vault");
|
||||
child = (await db.withHousehold(h, (c) => c.query("insert into members (household_id, display_name, role) values ($1, 'Kind', 'child') returning id", [h]))).rows[0].id;
|
||||
});
|
||||
|
||||
afterAll(async () => {
|
||||
await db.pool.end();
|
||||
await client.end();
|
||||
});
|
||||
|
||||
const token = (purpose: "login" | "verify", memberId = member, to = email) =>
|
||||
db.withAuth((c) => ml.createMailToken(c, { householdId: h, memberId, purpose, email: to }));
|
||||
const consume = (t: string) => db.withAuth((c) => ml.consumeMailToken(c, t));
|
||||
const find = (to: string) => db.withAuth((c) => ml.findMailMember(c, to));
|
||||
|
||||
it("an unconfirmed address cannot sign in; confirming sets it", async () => {
|
||||
expect(await find(email)).toBeNull();
|
||||
const login = await token("login");
|
||||
expect(await consume(login)).toBeNull(); // Adresse noch nicht bestätigt
|
||||
const verify = await token("verify");
|
||||
expect(await consume(verify)).toMatchObject({ purpose: "verify", memberId: member, email });
|
||||
expect(await find(email)).toMatchObject({ id: member, householdId: h });
|
||||
});
|
||||
|
||||
it("a link works once, and a newer one replaces the older", async () => {
|
||||
const first = await token("login");
|
||||
const second = await token("login");
|
||||
expect(await consume(first)).toBeNull();
|
||||
expect(await consume(second)).toMatchObject({ purpose: "login", memberId: member });
|
||||
expect(await consume(second)).toBeNull();
|
||||
expect(await consume("not-a-real-token-but-long-enough")).toBeNull();
|
||||
});
|
||||
|
||||
it("an expired link is refused", async () => {
|
||||
const t = await token("login");
|
||||
await db.withAuth((c) => c.query("update mail_tokens set expires_at = now() - interval '1 minute' where member_id = $1 and used_at is null", [member]));
|
||||
expect(await consume(t)).toBeNull();
|
||||
});
|
||||
|
||||
it("children never sign in by mail, and a taken address cannot be confirmed by someone else", async () => {
|
||||
const t = await token("verify", child, `kind-${h.slice(0, 8)}@test.example`);
|
||||
expect(await consume(t)).toBeNull();
|
||||
const other = (await db.withHousehold(h, (c) => c.query("insert into members (household_id, display_name, role) values ($1, 'Ben', 'member') returning id", [h]))).rows[0].id;
|
||||
const steal = await token("verify", other, email);
|
||||
expect(await consume(steal)).toBeNull();
|
||||
expect(await find(email)).toMatchObject({ id: member });
|
||||
});
|
||||
|
||||
it("sends nothing without a key, and writes the mail when set up; the key is stored sealed", async () => {
|
||||
const message = await ml.linkMail({ purpose: "login", to: email, token: "abc", origin: "https://lunch.test", locale: "de" });
|
||||
expect(message.text).toContain("https://lunch.test/anmelden/mail#login=abc");
|
||||
await expect(mail.sendMail(h, message)).rejects.toBeInstanceOf(mail.MailNotConfigured);
|
||||
const sealed = await vault.seal("re_secret_key");
|
||||
await db.withHousehold(h, (c) => c.query("update household_mail set password_enc = $1", [sealed]));
|
||||
const raw = (await db.withHousehold(h, (c) => c.query("select password_enc from household_mail"))).rows[0].password_enc as Buffer;
|
||||
expect(raw.toString("latin1")).not.toContain("re_secret_key");
|
||||
await mail.sendMail(h, message);
|
||||
const files = await readdir(process.env.MAIL_TEST_DIR!);
|
||||
const sent = JSON.parse(await readFile(path.join(process.env.MAIL_TEST_DIR!, files[0]!), "utf8"));
|
||||
expect(sent).toMatchObject({ to: email, from: "hallo@test.example" });
|
||||
expect(sent.html).not.toMatch(/<img/i);
|
||||
});
|
||||
|
||||
it("the mail escapes what goes into its HTML", () => {
|
||||
const m = mail.buttonMail({ to: "a@b.c", subject: "s", lead: "<script>x</script>", button: "b", url: "https://x.test/?a=1&b=2", note: "n" });
|
||||
expect(m.html).not.toContain("<script>");
|
||||
expect(m.html).toContain("a=1&b=2");
|
||||
});
|
||||
|
||||
it("confirming a new address ends the sessions that began with the old one", async () => {
|
||||
await db.withAuth((c) =>
|
||||
c.query("insert into sessions (token_hash, member_id, household_id, expires_at, via) values (sha256(convert_to($1, 'utf8')), $2, $3, now() + interval '1 day', 'mail')", [`s-${h}`, member, h]),
|
||||
);
|
||||
const count = async () => (await db.withAuth((c) => c.query("select count(*)::int as n from sessions where member_id = $1 and via = 'mail'", [member]))).rows[0].n;
|
||||
expect(await count()).toBe(1);
|
||||
const t = await token("verify", member, `neu-${h.slice(0, 8)}@test.example`);
|
||||
expect(await consume(t)).toMatchObject({ purpose: "verify" });
|
||||
expect(await count()).toBe(0);
|
||||
});
|
||||
|
||||
it("the sender name cannot break a mail header", async () => {
|
||||
await db.withHousehold(h, (c) => c.query("update household_mail set from_name = $1", ['Evil"\r\nBcc: x@y.z']));
|
||||
await mail.sendMail(h, mail.buttonMail({ to: "a@test.example", subject: "s", lead: "l", button: "b", url: "https://x.test", note: "n" }));
|
||||
const files = (await readdir(process.env.MAIL_TEST_DIR!)).sort();
|
||||
const sent = JSON.parse(await readFile(path.join(process.env.MAIL_TEST_DIR!, files.at(-1)!), "utf8"));
|
||||
expect(sent.from).toBe('"EvilBcc: x@y.z" <hallo@test.example>');
|
||||
});
|
||||
});
|
||||
@@ -153,7 +153,8 @@ describe.skipIf(!url)("row level security", () => {
|
||||
"select distinct tablename from pg_policies where schemaname = 'public' and qual like '%app_auth()%' order by 1",
|
||||
);
|
||||
expect(rows.map((r) => r.tablename)).toEqual([
|
||||
"auth_attempts", "auth_challenges", "households", "instance", "invitations", "kid_devices", "members", "passkeys", "sessions",
|
||||
// mail_tokens seit 26.11.40: der Mail-Link findet den Haushalt erst über die Adresse.
|
||||
"auth_attempts", "auth_challenges", "households", "instance", "invitations", "kid_devices", "mail_tokens", "members", "passkeys", "sessions",
|
||||
]);
|
||||
});
|
||||
});
|
||||