This package provides a mechanism to impersonate other accounts in a Neos Flow application. It includes a REST API for managing impersonation sessions.
The package should be placed in DistributionPackages/fucodo.accountSwitcher.
The package provides the following API endpoints (all returning JSON):
GET /api/v1/fucodo/accountswitcher/currentAccount: Get current impersonation status.POST /api/v1/fucodo/accountswitcher/switch: Switch to a different account.POST /api/v1/fucodo/accountswitcher/reset: Reset impersonation.
For detailed API documentation, see Documentation/openapi.yaml.
The following example demonstrates how to switch to another account using the API:
const response = await fetch(
`${window.location.origin}/api/v1/fucodo/accountswitcher/switch?accountIdentifier=sysadmin-2&authenticationProviderName=DefaultProvider`,
{
method: 'POST',
headers: {
'accept': 'application/json'
},
body: ''
}
);
const data = await response.json();
console.log(data);The following example demonstrates how to reset the impersonation session:
const response = await fetch(
`${window.location.origin}/api/v1/fucodo/accountswitcher/reset`,
{
method: 'POST',
headers: {
'accept': 'application/json'
},
body: ''
}
);
const data = await response.json();
console.log(data);The routes are automatically registered if the package is active. You can adjust the route position in Configuration/Settings.Neos.Flow.mvc.yaml.