In my website user can log-in with simple account (created in my website, configured MY_OWN_USER provider, which selects user by email) or using facebook log-in (integrated through fosfacebook bundle).
When i'm trying to impersonate user (appending link '[email protected]', like described in Symfony2 documentation) Symfony2 logs such warning:
security.WARNING: Switch User failed: "The user is not authenticated on facebook"
I've checked Symfony\Component\Security\Http\Firewall\SwitchUserListener and looks like by default it gets not MY_OWN_USER provider but fosfacebook provider which tries to select user by facebook_id (if i append link with '...?_switch_user=FACEBOOK_ID' - switch user works correctly!)
So how to make that SwitchUserListener would get MY_OWN_USER provider which selects user by email not by facebook id?
When configuring impersonation in your firewall config in
security.yml
, you can specify which provider should be used to find the user who is being impersonated (ref). For example:Hope this helps!