joselfonseca / lighthouse-graphql-passport-auth

Add GraphQL mutations to get tokens from passport for https://lighthouse-php.com/
https://lighthouse-php-auth.com/
MIT License
231 stars 55 forks source link

Social Login breaks if user signed up via email #98

Closed akshitkrnagpal closed 3 years ago

akshitkrnagpal commented 4 years ago

What is happening now Since the user signed up using email, the provider field is null and hence it tries to create an account, which also fails because email is already present.

What is expected When user login via Facebook, instead of throwing the error it should update the provider and provider_id if they are null.

BTW. Awesome work. Thanks. ❤️

joselfonseca commented 4 years ago

Hello there, This use case is not contemplated at the moment. I would be a nice enhancement, PRs are welcome!

dinhkhanh commented 4 years ago

This is nice to have. User may registered by email, later on they would like to login by Social accounts. Or in Account Settings page, they would like to connect their Social accounts.

It should automatically match their email-based account with Social ones.

joselfonseca commented 4 years ago

PRs are welcome!

th3error commented 4 years ago

I just ran into this yesterday. I fixed it by simply checking whether the user's email exists but the provider & provider_id are not matching that of the request, which in my case means they're empty. I only use Facebook for social login in my app so these fields either have data or they don't. If the email is there, I update that user and add the provider and provider_id.

This is done before the Try Catch. I can submit a PR, but I don't think this solution would accomidate more than one provider/user.

akshitkrnagpal commented 4 years ago

I fixed it by simply checking whether the user's email exists but the provider & provider_id are not matching that of the request, which in my case means they're empty.

Yes. This is exactly what I do in my app.


@joselfonseca I see you have self-assigned yourself. May I ask what scope do you have in mind? Ideally, we would like to connect multiple social accounts to a single user.

joselfonseca commented 4 years ago

@akshitkrnagpal I was thinking on supporting multiple although I never had that use case before. Usually only one was required. I removed the assignation in case anyone wants to work on it since I haven't had a lot of time

joselfonseca commented 3 years ago

This is addressed in the PR https://github.com/joselfonseca/lighthouse-graphql-passport-auth/pull/130. However it includes a breaking change for good.