trails/apps/journal/app/routes/api.settings.profile.ts
Ullrich Schäfer be5766fa50
Add account settings page with passkey management
- /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>
2026-03-29 10:09:06 +02:00

23 lines
789 B
TypeScript

import { data, redirect } from "react-router";
import { eq } from "drizzle-orm";
import type { Route } from "./+types/api.settings.profile";
import { getSessionUser } 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 formData = await request.formData();
const displayName = (formData.get("displayName") as string)?.trim() || null;
const bio = (formData.get("bio") as string)?.trim().slice(0, 160) || null;
const db = getDb();
await db
.update(users)
.set({ displayName, bio })
.where(eq(users.id, user.id));
return data({ ok: true });
}