-
-
Notifications
You must be signed in to change notification settings - Fork 797
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Auto register users after login with facebook #116
Comments
Any advice on this? |
I have the same problem. Could someone please provide an example how to integrate this correctly? @dmontero You should change your Facebook and Twitter API secrets because they are exposed now! |
this works for me, the /login is defined by the FOSUserBundle : you can check your routing rules : php app/console router:debug
|
I have a similar problem and even with the above configuration won't solve it. When someone tries registering by connecting with Facebook, they get the error "User '123456' not found." Can this be made to work? Where is the user creation handled? I'm asking for the |
A cleaner implementation could be to redirect the user to a registration form, which is prepopulated with basic info from Facebook. |
Not sure it would be cleaner but it would certainly be a much worse user experience, rather than just clicking to be registered and logged in. |
I find a way to do this, but I don't know if is safe. Create your own FOSUserProvider, override loadUserByOAuthUserResponse
|
Thanks! That worked perfectly. |
Auto registering users after login might not be the best idea (IMO), but if you really want to do it look at the snippet above. :) |
@asm89 Want to elaborate any further why it is not a good idea? What should one do instead? |
@daFish in the above snippet, it may really hurt you if OAuth server does not provide user email address. |
@osmialowski Yeah, after some more thought about the whole workflow, sending the user to the registration page with pre-filled fields seems to be much more robust than just trying to create the user. |
@daFish how would you go about doing that? |
@aequasi I haven't had time to try it out myself but you could do the following:
|
@daFish I would like to implement what you are suggesting, but where should this fos_user_registration_register redirect happen, in FOSUBUserProvider->loadUserByOAuthUserResponse ? What happens with tokens and with oauth provider data after redirect (should they be persisted in session?) |
@pentarim That is exactly what I'd tried to do but ultimately failed. I used a |
@daFish Did you manage to redirect the user to a registration form after a succesful OAuth response? I'm facing the same problem. In my custom user provider I issue a redirect but the controllers expects a User object not a redirect response. Any ideas how you implemented this? I sa the registrationAction in the ConnectController but I can't reach this... |
i am also facing the same issue , can any one please help me how to solve it ? |
@devswaam Did you try to implement a custom user provider and have it look up existing users or create new ones on the fly? Else see @yplam's suggestion above — it worked perfectly for me. |
The built-in However, if you override the In config.yml tell HWIOAuth2 to override the user provider:
Overriding the
|
@ryancastle Would you mind to add some documentation how to nicely connect already existing users. It might be already covered in some way in the docs but this isn't intuitive. This would certainly help many people. |
Yes. When I'm finished my current implementation I was planning to fill in some of the missing steps in the docs. |
@ryancastle 👍 |
@zazzou This gist should not be considered as a good practice. |
@aosmialowski could you provide a better one? |
@matheo Yes, for this specific use case. And for this use case, the gists provided is not a good solution. I'd say it's terrible solution. Check out this blog post: http://www.osmialowski.co.uk/symfony-2-oauth-better-way-integrate-hwioauthbundle-fosuserbundle/. |
@aosmialowski I suspect that However, the default implementation that forces users to explicitly login and "connect" their accounts is not that nice either. |
@ryancastle but you are also wrong. The At the begining of the process, the user is checked by ID returned from resource owner (and the resource owner name in my approach). |
@aosmialowski Ah yes. You are right. |
this is the updated link from @aosmialowski answer, the old link is broken |
@aosmialowski You wrote on 22 Jan 2013 "@daFish in the above snippet, it may really hurt you if OAuth server does not provide user email address." But in your example on github (https://github.com/aosmialowski/FOSUserBundle-HWIOAuthBundle-integration/blob/master/src/Owl/UserBundle/Security/User/Provider/OAuthUserProvider.php) you do it the same way?! I also did it like that, but as you said, sometimes there is no email provided... So sending the user to a pre-filled sign up form is in my opinion the best way. |
@dappl In this snippet yes, but in real world application I have a listener which checks for user email address. If there's no email supplied user gets redirected to the "Add email" form. Without providing email, user can do nothing on the website (in this particular example). Pre-filled sign up form? It's against the idea of form-less registration via 3rd party services IMHO. |
@aosmialowski Can you provide and example how to correctly redirect from OAuthUserProvider to "Add email" form? I would like to ask users for phone number, so I need to redirect them to a form before creating user. Thank you. |
@milokmet Depending on your use-case you can throw a custom exception, then create a listener that would handle thrown exception and redirect user to proper form. |
From OAuthUserProvider, how can I send a registration confirmation email and then redirect to "/register/check-email" ? |
Hi! I'm new to HWIOauth, and I've been experimenting with this great bundle and FOSUserBundle for a few days. I had several problems with the routing, configuration, etc. But now I'm being able to connect a facebook account to a registered (and logged) user. If the user is not registered and I send him to http://mysite.dev/connect/facebook I get this error: No route found for "GET /connect"
¿What am I doing wrong? I want a new user to just log-in using his facebook account and save him in the user's list.
My config.yml file
My security.yml
My routing.yml
Thanks in advance
The text was updated successfully, but these errors were encountered: