Skip to content
This repository has been archived by the owner on Apr 17, 2020. It is now read-only.

Great work, question about creating accounts #13

Open
bertomartin opened this issue Aug 17, 2015 · 7 comments
Open

Great work, question about creating accounts #13

bertomartin opened this issue Aug 17, 2015 · 7 comments
Assignees

Comments

@bertomartin
Copy link

When a user logs in for the first time with her (his) social account, will this create an account in the user model? If an account is created, is there a flow that allows this user to create her password, so that for instance she can come back to the site and login with her email and password, if she decided not to login with facebook. Looking forward for your answer, and really appreciate the great work.

@marcoow
Copy link
Member

marcoow commented Aug 18, 2015

The only thing that's created on the first Facebook login is a Login model for that Facebook account. There is no user created automatically as the engine cannot know how to do that, what the required fields are etc. Of course it should be possible though to register a hook or so that's called whenever a new Login is created via someone signing up with Facebook. Would you have a suggestion for that?

Changing or setting the password for a Facebook Login afterwards is of course possible and would just be an update of the Login model. The engine doesn't provide anything for that but all you need is actually the current_login helper that returns the authorized Login model that you can then call #update! on.

@bertomartin
Copy link
Author

Thanks for the answer. I think having some sort of register hook makes sense since the user flow I described happens quite a bit in my experience. I'll play around with it and see what I can come up with.

@marcoow
Copy link
Member

marcoow commented Aug 18, 2015

I guess it would probably make sense to provide that hook specifically for the case when a new Login is created via a new signup via Facebook instead of providing e.g. a general option to register an after_create on the Login model or so as that would actually not be needed when the app creates the Login model when a new user is created (e.g. when signing up with login and password).

It might make sense to simply add a new config option on_facebook_signup or so that would be configured as a block that the Facebook auth service calls when creating a new Login model and that would execute in a transaction that also the Login creation runs in.

@marcoow
Copy link
Member

marcoow commented Aug 21, 2015

@oliverbarnes: maybe you'd have an idea and time to come up with a PR?

@oliverbarnes
Copy link
Contributor

Hey, sorry for the (hugely) delayed response! So, I'm not sure I get the need for the hook... Wouldn't an endpoint to update the existing Login with an email / password pair solve that, as @marcoow suggested on his first response?

Changing or setting the password for a Facebook Login afterwards is of course possible and would just be an update of the Login model. The engine doesn't provide anything for that but all you need is actually the current_login helper that returns the authorized Login model that you can then call #update! on.

@marcoow
Copy link
Member

marcoow commented Mar 2, 2016

The point is that users might be signing up to the service via authenticating via Facebook. In that case the application that uses this engine would want to create a record of its internal User (or whatever the app uses) model. That's what we need to have a hook for - creating an instance of the associated user model when a new instance of Login is created (if that's not already associated to the user).

@talhaobject90
Copy link

talhaobject90 commented Nov 28, 2016

Great enhacement idea, I appreciate the work, Is creating new user when new facebook login is implemented ? .
I made an ember app with torri - simple-auth combination , i could authenticate , but cannot create a user data into the user model
I am stuck here.
or is there any other working plugins? will the devise-omniauth combination works?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants