I have managed to install this… and make it work. I will present my solution. All the code is available in [this Gist] (https://gist.github.com/4476697). Mostly it is as described in #116, with a bit of more code presented. The key aspects that lack in the #116 presentation (IMO) are:
- the registration as service of your custom FOSUBUserProvider (with the necessary parameters)
- set the service for
oauth_user_provider
in thesecurity.yml
with your custom created service
Here are the steps:
- Routing. In
routing.yml
I have added all the routes for both bundles. - Configuration. I have set the
config.yml
mostly as it is presented in the HWIOAuthBundle. - Security. I have set the
security.yml
mostly as it is presented in the HWIOAuthBundle (though my routes are using/login
pattern, not/connect
). Also, theoauth_user_provider
is set for my custom service. - User. My own User entity, extended from FosUser.
- UserProvider. My user provider, registered as service, extended from FOSUBUserProvider. This is the one that actually does the User registration in YOUR database with data from PROVIDERS (Facebook, Google, etc.)
- Custom service. My user provider is registered as service.
Using this code, when:
- No user is authenticated on my site: by accessing
http://my_app_web_root/login/facebook
orhttp://my_app_web_root/login/google
, a user is created in my database (with data as it is saved in the custom FOSUBUserProvider) and it is automatically login-ed to my site. - A user is authenticated on my site: by accessing
http://my_app_web_root/login/facebook
orhttp://my_app_web_root/login/google
, the current user is updated with data from the provider (account linking).
I think this is the behavior everybody was expecting :).
@northern see if this helps you: http://stackoverflow.com/questions/30726822/hwioauthbundle-cant-redirect-after-successfull-connection