Question

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 '...?_switch_user=demo@demo.com', 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?

Was it helpful?

Solution

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:

switch_user:
    provider: MY_OWN_USER

Hope this helps!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top