Skip to content
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

Remove "AND provider='email'" from SQL when login #266

Closed
casertap opened this issue Jun 8, 2015 · 8 comments
Closed

Remove "AND provider='email'" from SQL when login #266

casertap opened this issue Jun 8, 2015 · 8 comments

Comments

@casertap
Copy link

casertap commented Jun 8, 2015

Hi,
I want my users to be able to login with facebook and email to the same account.
The problem with devise_token_auth is that it check the provider field on login:

  SELECT  `users`.* FROM `users` WHERE (BINARY email = 'aaaaa@gmail.com' AND provider='email')  ORDER BY `users`.`id` ASC LIMIT 1 

Is it possible to remove the "AND provider='email'" from the conditional? Or do you have another way to resolve my problem.

@nicolas-besnard
Copy link
Contributor

If your users want to connect via Facebook, you use the Facebook Connect button, otherwise, they use their emails.

@casertap
Copy link
Author

casertap commented Jun 8, 2015

ok let say my user connected with facebook first. The provider field is set to 'facebook'.
Now my user logout and log again but with email and password. The sql
SELECT users.* FROM users WHERE (BINARY email = 'aaaaa@gmail.com' AND provider='email') ORDER BY users.id ASC LIMIT 1

does not find any user because the provider of my user was set ta 'facebook'

@nicolas-besnard
Copy link
Contributor

I think your user need to connected via email first, then you can link his Facebook account with it.

You might need additional fields such as "facebook_id" and you'll need to change the query made on login.

@casertap
Copy link
Author

Hi nicolas, thanks for your answers.
I was testing what you propose has a solution and I am wondering how I can change the query that is done at login because this query is done in the devise_token_auth gem.
The solution to my problem will be to not care about the provider field at all.

@nicolas-besnard
Copy link
Contributor

As the SessionsController is located in app/controller/devise_token_auth, you can create a new controller at this place and it'll override the one provided by this gem.

You can also create a new controller in any places you want and specify in your routes.rb the right controller to use.

@casertap
Copy link
Author

Thanks for the quick answer. I let you know if I have problems.

@casertap
Copy link
Author

Actually, it is very difficult for me to progress because of the issue I get when connecting to facebook: #268

@MaicolBen
Copy link
Collaborator

Resolved in #964

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

No branches or pull requests

3 participants