---
title: "Impersonation"
description: "Why an administrator acts inside an account or a workspace only by visiting it as the person, what a visit may and may not do, how long it lasts, and how the app says so."
canonical_url: "https://nuxt-backend.dev/docs/build/auth/admin/impersonation"
---
# Impersonation

> Why an administrator acts inside an account or a workspace only by visiting it as the person, what a visit may and may not do, how long it lasts, and how the app says so.

Version: nuxt-backend 0.6.x · Tab: Build · Kind: concept · Status: stable

Every page: [llms.txt](https://nuxt-backend.dev/llms.txt) · Skill for coding agents: [nuxt-backend](https://nuxt-backend.dev/.well-known/skills/nuxt-backend/SKILL.md)

Commands use npm; use your project's package manager.

- [API reference](https://nuxt-backend.dev/docs/reference/api/admin)
- [Source](https://github.com/qruto/nuxt-backend/blob/main/src/convex/client/guards.ts)

An administrator sees every account and every workspace in the [admin console](https://nuxt-backend.dev/docs/build/auth/admin), and changes none of them from the outside. To help someone, an administrator **impersonates** them. The browser's session becomes a visit of that account, and the app shows exactly what the person sees. Every step lands on the activity trail. Acting through a visit, rather than through powers of its own, keeps support work in the person's shoes, and leaves nothing behind.

Better Auth's admin plugin opens and ends the visit. The package shortens it, refuses visits to administrators, holds a visit to a short list of routes, and says so on every page.

## A visit is short, and never of an administrator

- **Thirty minutes at most.** A visit's session ends on its own after `IMPERSONATION_SESSION_SECONDS`, from `nuxt-backend/admin`. An app's own `admin.impersonationSessionDuration` may only shorten it. When it ends, the administrator signs in again as themselves.
- **Never an administrator's account.** A visit to an account that holds an administrator role, the caller's own included, is refused as `forbidden` with reason `admin_target`, whatever the app's roles grant. A caller who may not impersonate at all is refused first, and learns nothing about who holds an administrator role.
- **Starting one takes a recent sign-in.** An administrator whose sign-in is older than ten minutes confirms it's them first.

## What a visit may and may not do

The auth routes hold a visit to an allowlist, the routes whose row of the [sensitive-action table](https://nuxt-backend.dev/docs/build/auth/access/step-up#which-actions-ask) allows it. Everything else is refused with `forbidden` (reason `impersonating`), including any route a plugin adds later.

A visit may:

- read the session, the devices, the passkeys, the workspaces, their members and invitations;
- keep the visit going, and end it, which always returns the administrator to their own session;
- do the support work a visit is for: change the profile's name and image, switch, create or rename a workspace, and withdraw or decline an invitation.

A visit may not, among the rest: add or remove a passkey, change the email address, delete the account or a workspace, sign the account's devices out, invite, remove or change the role of anyone, join or leave a workspace, export the account's data, or use any other admin route.

The package's own functions refuse a visit wherever the person's money or access is at stake. That covers spending credits and metered AI, checkout, the billing portal and the plan's lifecycle. It also covers buying or claiming a gift, signing devices out, every write of the `admin` tier, and the admin console's reads. Refuse the same in your own functions with `impersonation: 'refused'` beside `args` ([Protect backend functions](https://nuxt-backend.dev/docs/build/auth/access/functions#ask-more-of-one-function)).

## How the app says so

- **<BackendNotices>.** The one region for app-wide notices shows the visit first: whose account this is, and when the visit ends. Its **Stop impersonating** button returns to the administrator's session, and reloads the app at the admin console. Every packaged page renders the region. Put it in your layout so your own pages say it too ([UI](https://nuxt-backend.dev/docs/build/ui)):```vue [app/app.vue]
<template>
  <BackendNotices />
  <NuxtPage />
</template>
```
- **useAuth().impersonating** is `true` during a visit, and `useAdmin().stopImpersonating()` ends it from your own markup.
- **The activity trail.** The visit's start and end are recorded by the administrator (`admin.impersonation_started`, `admin.impersonation_stopped`). Every event recorded during it carries the administrator as `impersonatorId`. In the account's own activity, the administrator is unnamed: "An administrator began acting as you".

## What this means for you

- Help someone by visiting their account from the admin console, never by giving administrators a power over accounts. What the visit can do is what the person can do, minus anything sensitive.
- Render `<BackendNotices />` in your layout, so nobody mistakes someone else's account for their own.
- Refuse a visit in your own functions where money or access is at stake: `impersonation: 'refused'`.
- Expect the trail to name the administrator behind every event of a visit, and the account's own activity to keep them unnamed.

## Related

- [Run the admin console](https://nuxt-backend.dev/docs/build/auth/admin): starting a visit, from an account or a workspace's member.
- [Record and review activity](https://nuxt-backend.dev/docs/build/auth/admin/audit-log): where every visit is recorded.
- [Require a recent sign-in](https://nuxt-backend.dev/docs/build/auth/access/step-up): the table a visit is held to.


## Sitemap

See the full [sitemap](https://nuxt-backend.dev/sitemap.md) for all pages.
