simi / omniauth-facebook

Facebook OAuth2 Strategy for OmniAuth
https://simi.github.io/omniauth-facebook/
1.26k stars 403 forks source link

Separating Sign up and Sign in #376

Closed deniciocode closed 2 years ago

deniciocode commented 2 years ago

Hello,

I have a questions regarding the usage of omniauth and specially omniauth-facebook. We want to offer social login on our platform. If a new user wants to signup, everything is clear. New user will be created on the callback. Done. How do I handle a user who tries to sign in, but never signed up with facebook before. With this step I would like to protect an existing user (email/password) to try to login with facebook, which will result in the creation of a new user if we have different emails.

swiknaba commented 2 years ago

I think this is best asked on Stackoverflow since that is an engineering challenge to be solved in your codebase. It is not really related to this gem.

You'll have the same problem with any OAuth login flow.

Quick thoughts: From the OAuth flow, you receive a unique ID from facebook ("uid"). You can store that in your users table, and on sign-in check if you have a user with that uid or not. From there you can continue the flow for the user.

deniciocode commented 2 years ago

The question is, how to a differentiate sign in and sign up.

Steps

I am not sure where to hook in. On the visit /auth/:provider is there any change to pass data (like Query params) catch it on a controller and continue with omniauth?

deniciocode commented 2 years ago

I am not sure, but I think by using state param, I am able to separate a login.

swiknaba commented 2 years ago

great you found a solution. Thanks for updating the issue :-)