xlite-dev/filament-impersonate
Filament plugin to switch between accounts without signing out. Supports linked accounts, impersonation with a switch-back banner, and environment-gated developer logins, plus an audit trail and a fluent per-panel API. Formerly xlite-dev/filament-impersonate.

Switch between accounts in a Filament panel without signing out — safely, in production.
ImpersonateAction for your user resource, a persistent banner with a Switch back button, and authorization hooks on your model.AccountSwitching / AccountSwitched events.Formerly xlite-dev/filament-impersonate — see the upgrade guide.
| Plugin | Filament | Laravel | PHP |
|---|---|---|---|
| 4.x | 4.x, 5.x | 12.x, 13.x | 8.2+ |
3.x (xlite-dev/filament-impersonate) |
4.x, 5.x | 9.x – 12.x | 8.1+ |
composer require packstub/filament-account-switcher
php artisan packstub-account-switcher:install
Add the trait to your user model and the plugin to your panel:
use Packstub\AccountSwitcher\Concerns\HasLinkedAccounts;
class User extends Authenticatable implements FilamentUser
{
use HasLinkedAccounts;
public function canImpersonate(User $target): bool
{
return $this->hasRole('super-admin');
}
}
use Packstub\AccountSwitcher\AccountSwitcherPlugin;
$panel->plugin(
AccountSwitcherPlugin::make()
->developerLogins(['[email protected]', '[email protected]']),
);
Full walkthrough: Installation.
Link the accounts one person owns. A Switch to menu next to the user menu lists them with their label and e-mail.

Switching down to a lower-privilege account is one click. Switching up asks for the target account's password, so a compromised daily session can never reach the admin account on its own.

The Linked accounts page (in the user menu) links an existing account, creates a sub-account, renames links and sets the per-link password rule.

// Or link programmatically — one click down, password up
$admin->linkAccount($daily, label: 'Daily', requiresPassword: false);
Read more: Linked accounts · Security model.
Drop ImpersonateAction into your users table or a page header. It is hidden for records the current user may not impersonate, based on canImpersonate() / canBeImpersonated() on your model.
use Packstub\AccountSwitcher\Filament\Actions\ImpersonateAction;
->recordActions([
ImpersonateAction::make(),
])

While impersonating, a banner stays visible on every page with a Switch back button.

Read more: Impersonation.
One-click sign-in for the accounts you seed, shown under the login form. They only render in the environments listed in the config (local by default), whatever the panel says.
AccountSwitcherPlugin::make()
->developerLogins(['[email protected]', '[email protected]'])

Read more: Developer logins.
AccountSwitcherPlugin::make()
->impersonation() // on by default
->linkedAccounts() // on by default
->developerLogins(['[email protected]']) // off by default
->canImpersonateUsing(fn (User $by, User $target) => $by->can('impersonate', $target))
->canSwitchUsing(fn (User $from, User $to) => ! $to->is_locked)
->banner(position: 'top', style: 'light')
->redirectTo('/admin')
Read more: Configuration — the config file, events, the switch log and the AccountSwitcher facade.
The same pages live in the docs/ directory of this repository.
composer test
See the changelog.
Please e-mail [email protected] rather than opening a public issue.
MIT. See the license file.
How can I help you explore Laravel packages today?