Skip to content

Impersonation

Admin users can impersonate others via RFC 8693 token exchange. Register the routes and navigate — the library handles the rest.

app.routes.ts
import { Routes } from '@angular/router';
import {
createAuthCallbackRoute,
createStartImpersonationRoute,
createEndImpersonationRoute,
} from '@presencelearning/auth';
export const routes: Routes = [
createAuthCallbackRoute(),
createStartImpersonationRoute(),
createEndImpersonationRoute(),
// ...
];
// Trigger impersonation from any component
router.navigate(['/auth/impersonate', userId], { queryParams: { path: '/dashboard' } });
// End impersonation
router.navigate(['/auth/end-impersonation']);

AuthService exposes the impersonation-aware state:

authService.isImpersonating(); // Signal<boolean>
authService.currentUser(); // Signal<User | null> — impersonated user while active
authService.accessToken(); // Signal<string | null> — impersonation token while active
authService.originalUser(); // Signal<User | null> — the real admin user

Cross-app impersonation redirect: navigating between apps while preserving an active impersonation session is not supported. Each app performs its own RFC 8693 token exchange.