Add read-only admin impersonation

Admins (with 2FA) can view the site as a non-admin user for up to 30
minutes, with a required reason and a "Viewing as" banner. It is
strictly read-only: a guard mounted before every route refuses any
write made with an impersonation token, protect/optionalAuth check the
session is live, and GET handlers skip the price-refresh writes. Start,
end, reason and every page/API call (including blocked attempts) are
audited; optional email to the user.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CP62L9JxHomA36aYP1ekCe
This commit is contained in:
2026-10-19 18:25:02 +02:00
co-authored by Claude Opus 5.5
parent 6b958884d6
commit bd7e5e8e0e
22 changed files with 642 additions and 6 deletions
@@ -1,5 +1,5 @@
import React from "react";
import { Users, UserPlus, ShieldAlert } from "lucide-react";
import { Users, UserPlus, ShieldAlert, Eye } from "lucide-react";
import { GuideItem } from "@/components/shared/GuideItem";
import type { HelpContent } from "./types";
@@ -30,6 +30,9 @@ export const dashboardAdminUsersHelpContent: HelpContent = {
content: (
<div className="space-y-4">
<div className="space-y-4">
<GuideItem icon={Eye} title="Impersonate" tone="violet">
See the site exactly as a user does, to help with a problem (&quot;my ticket isn&apos;t showing&quot;). Give a reason. A bright banner shows while you&apos;re viewing, for up to 30 minutes. It&apos;s strictly read-only: nothing can be registered, paid, changed or sent. The reason and every page you open are recorded in the audit log. You need two-factor authentication on, and admins can&apos;t be impersonated. Optionally, users get an email when this happens (Site Settings → Legal → Support access).
</GuideItem>
<GuideItem icon={Users} title="Sign out everywhere" tone="amber">
Revokes all of that user&apos;s active sessions — useful if a device was lost or access needs to be cut immediately.
</GuideItem>