# Impersonation

> How an admin sees the app as a user: the step-up code, the banner, the one-hour limit and what an impersonating session can't do.

*Canonical: https://makerkit.dev/docs/void-cloudflare/admin/impersonation*

---

Impersonation lets support see the app as a user sees it, to reproduce a problem. It is built to be seen and limited, not to take an account over.


{% img src="/assets/images/docs/void-cloudflare/admin-user.png" width="1440" height="900" alt="An admin viewing a synthetic user and their active sessions in dark mode." /%}

An admin viewing a synthetic user and their active sessions in dark mode.

## Starting

On the user's admin page, **Impersonate** asks for a code emailed to the **admin** (a [step-up code](../authentication/step-up-codes)). Right code, and the admin is signed in as the user. The admin's own session is kept aside and comes back when they stop.

Refused: another admin, yourself and a banned user. An account holding an admin role is never impersonated.

## While Impersonating

- A yellow banner is fixed at the top of every page: who you are signed in as, and **Stop**.
- `/admin` answers 404: the session is the user's. Stop first.
- The session ends **one hour** after it started, whatever its expiry says, and the admin is signed out (not returned).
- Signing out clears the admin's kept-aside session too.
- Starting and stopping are logged with both ids (`admin.impersonation_started`, `admin.impersonation_stopped`).

## What Is Refused

An impersonating session can't change the user's account security or read their credentials. Over HTTP (`/api/auth`) it may only read itself, sign out and use the organization switcher; every other Better Auth endpoint answers 403, including any a future upgrade adds. The security settings page says so instead of showing its forms. Among the refused:

- two-factor (turn on, off, new backup codes)
- password and email changes
- passkeys (add, rename, delete)
- linked accounts (link, unlink)
- signing out other sessions, and account deletion
- the user's provider tokens (`/get-access-token`, `/refresh-token`, `/account-info`) and their other sessions (`/list-sessions`)

Everything else works as the user: the admin sees their data and can act in the app. Treat it as acting as that person.

## Stopping

**Stop** (the banner) returns the admin to the user's admin page. A demoted or banned admin keeps an impersonation session for up to its hour: the limit, the banner, the logs and the [audit log](../audit/overview) are the safeguards.

## Customizing

The hour is `IMPERSONATION_MAX_MINUTES` in `@kit/better-auth`. The browser allowlist is `IMPERSONATION_HTTP_PATHS` in `packages/better-auth/src/admin.ts`: add a path only if the impersonated user's own pages need it. The app's own server code reads as the user through `auth.api`, where only the denylist (`ACCOUNT_SECURITY_PATHS`) applies.
