EXPLANATION
Allowing user to switch to any other user is easy in Symfony2. My question is, how to allow certain user to switch only to certain other users? I'm using FOSUserBundle as my users provider.
EXAMPLE
There is 5 users, UserA, UserB, UserC, UserD, UserE, but only 3 of them are linked together.
UserA can switch to UserB and UserC
UserB can switch to UserA and UserC
UserC can switch to UserA and UserB
Thanks for your help!
To impersonate another user, the impersonator selects the Impersonate icon on the far right of the Tab Bar and selects the user from the Impersonate drop-down list. To stop impersonating a user, the impersonator clicks the Impersonate icon and selects Stop Impersonate from the Impersonate drop-down list.
Impersonate a user Users or Contacts. Click the name of an individual user to view the detail page. Click the Impersonate link next to the user's name.
You could possibly implement this type of thing by overriding the default SwitchUserListener.
The parameter you would override is: security.authentication.switchuser_listener.class
For example, in parameters.yml:
parameters:
security.authentication.switchuser_listener.class: My\Project\Security\Listener\SwitchUserListener
Where, in your custom listener class, you'd implement Symfony\Component\Security\Http\Firewall\ListenerInterface
and use the existing Symfony\Component\Security\Http\Firewall\SwitchUserListener
class as a basis for your custom implementation.
If you want to impersonate Admin Users in to Regular user there are some examples :)
https://gist.github.com/1589120
http://symfony.com/doc/current/book/security.html#impersonating-a-user
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With