问题
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?
回答1:
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!
来源:https://stackoverflow.com/questions/12916510/symfony2-unable-to-impersonate-user-when-website-log-in-using-two-different-use