SPB Git
1.3 KB · 13 lines tsx
1import { requireUserPage } from "@/lib/auth/guard";2import { db, schema } from "@/db";3import { eq } from "drizzle-orm";4import { SecurityPanel } from "@/components/admin/security-panel";5export default async function Settings({ searchParams }: { searchParams: Promise<{ must_change?: string }> }) {6  const s = await (async () => { try { return await requireUserPage(); } catch { return null; } })();7  const { getSession } = await import("@/lib/auth/session"); const sess = s ?? (await getSession());8  if (!sess) return null;9  const creds = await db.select({ id: schema.webauthnCredentials.id, label: schema.webauthnCredentials.label, createdAt: schema.webauthnCredentials.createdAt, lastUsedAt: schema.webauthnCredentials.lastUsedAt }).from(schema.webauthnCredentials).where(eq(schema.webauthnCredentials.userId, sess.id));10  const must = (await searchParams).must_change === "1" || sess.mustChangePassword;11  return <div className="mx-auto max-w-3xl"><h1 className="display h1">Settings & security</h1>{must && <p className="mt-3 rounded-xl border border-warn/40 bg-warn/10 p-3 text-sm">You must change the initial password before using the admin area.</p>}<SecurityPanel email={sess.email} totpEnabled={sess.totpEnabled} passkeys={JSON.parse(JSON.stringify(creds))} mustChange={must} /></div>;12}13
Files · main
Menu

Theme