- /settings with profile, security, and account sections - Profile: edit display name and bio - Security: list passkeys with device labels, add/delete with last-passkey warning - Account: email change with magic link verification, account deletion with username confirmation - Settings link in nav for authenticated users - E2E tests: auth guard, profile editing, passkey add/delete, last-passkey warning, account deletion, nav visibility - i18n: full en + de translations for all settings UI Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
19 lines
728 B
TypeScript
19 lines
728 B
TypeScript
import { redirect } from "react-router";
|
|
import { eq } from "drizzle-orm";
|
|
import type { Route } from "./+types/api.settings.delete-account";
|
|
import { getSessionUser, destroySession } from "~/lib/auth.server";
|
|
import { getDb } from "~/lib/db";
|
|
import { users } from "@trails-cool/db/schema/journal";
|
|
|
|
export async function action({ request }: Route.ActionArgs) {
|
|
const user = await getSessionUser(request);
|
|
if (!user) throw redirect("/auth/login");
|
|
|
|
const db = getDb();
|
|
|
|
// Delete user — credentials, magic_tokens, routes, activities cascade via FK
|
|
await db.delete(users).where(eq(users.id, user.id));
|
|
|
|
const cookie = await destroySession(request);
|
|
return redirect("/", { headers: { "Set-Cookie": cookie } });
|
|
}
|