Files
lunch/components/auth/setup-form.tsx
T
Kai BöhmandClaude Opus 5.5 f423dd67ce
ci / olares chart · sanity (pull_request) Successful in 3s
ci / app · types + tests + build (pull_request) Successful in 3m7s
markt / eintrag (pull_request) Successful in 29s
release / which version (pull_request) Successful in 3s
release / olares chart · sanity (pull_request) Successful in 4s
release / app (pull_request) Successful in 59s
release / tag and release (pull_request) Skipped
Own sign-in with passkeys, open the entrance, market entry (26.11.2)
Setup with a code from /app/data, passkeys with required user
verification, sessions as hashed cookies bound to the passkey they
started with, single-use invitation and device links, removing a
passkey or a member, and a recovery code for the owner. Cross-household
lookups before sign-in run in withAuth() (app.auth), allowed only on the
sign-in tables; a test pins that list. State-changing routes check the
session and the Origin header.

Security check with the login-sicherheit skill before the first
invitation: docs/sicherheit/login-2026-11-06.md (no open findings above
low). Entrance goes public now that the own sign-in exists; markt.yml
creates the Lunch entry in aimighty-market and proves it with wrangler.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HUc2nv7rJVU2gp3Bgtha3q
2026-11-06 19:26:36 +00:00

55 lines
2.1 KiB
TypeScript

"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";
import { register, type ErrorKey } from "./passkey";
export function SetupForm() {
const t = useTranslations("auth");
const router = useRouter();
const [error, setError] = useState<ErrorKey | null>(null);
const [busy, setBusy] = useState(false);
async function onSubmit(event: React.FormEvent<HTMLFormElement>) {
event.preventDefault();
const form = new FormData(event.currentTarget);
setBusy(true);
setError(null);
const result = await register(
"/api/auth/setup/options",
{ code: form.get("code"), name: form.get("name"), household: form.get("household") },
"/api/auth/setup/verify",
);
setBusy(false);
if (result) setError(result);
else router.replace("/");
}
return (
<form onSubmit={onSubmit} className="flex flex-col gap-4">
<div className="flex flex-col gap-2">
<Label htmlFor="code">{t("setup.code")}</Label>
<Input id="code" name="code" required autoComplete="one-time-code" autoCapitalize="characters" spellCheck={false} placeholder="XXXX-XXXX-XXXX-XXXX" />
</div>
<div className="flex flex-col gap-2">
<Label htmlFor="name">{t("setup.name")}</Label>
<Input id="name" name="name" required maxLength={60} autoComplete="given-name" />
</div>
<div className="flex flex-col gap-2">
<Label htmlFor="household">{t("setup.household")}</Label>
<Input id="household" name="household" required maxLength={80} placeholder={t("setup.householdPlaceholder")} />
</div>
{error ? <ErrorNotice>{t(`errors.${error}`)}</ErrorNotice> : null}
<Button type="submit" size="lg" disabled={busy}>
{busy ? t("working") : t("setup.submit")}
</Button>
<p className="text-sm text-muted-foreground">{t("setup.passkeyHint")}</p>
</form>
);
}