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

Multiple providers per user #594

Closed
cars10 opened this issue Mar 31, 2016 · 8 comments
Closed

Multiple providers per user #594

cars10 opened this issue Mar 31, 2016 · 8 comments

Comments

@cars10
Copy link

cars10 commented Mar 31, 2016

So i need users to be able to login with facebook, google, email and some other providers - and they have to land in the same account. With the default config of devise_token_auth it will create a new user for each provider and that sucks. I have an extra model called accounts that belongs to my user model where i manage these accounts.

To make that work i have to override like 500 things in devise_token_auth because the provider & uid columns are hardcoded in alot of places and cannot be removed per default. (obviously i do not need them because i handle that in a seperate model).

Is there a better way to solve that problem?

Edit: i am already thinking about a fork to solve that problem at the root.

@konpa
Copy link

konpa commented Apr 5, 2016

I'm interested in doing the same thing. Any update on this?

@cars10
Copy link
Author

cars10 commented Apr 5, 2016

I ended up not using this gem. Implemented tokens myself, combine the following two gists:

@konpa
Copy link

konpa commented Apr 5, 2016

Thanks for your feedback. My app is already configured with devise token auth & ng token auth (using only the email provider at the moment) and I'm not sure yet if I want to switch to something else... It's a shame because I'd really like to be able to connect with other providers and I can't figure how to get this working for now...

@cars10
Copy link
Author

cars10 commented Apr 6, 2016

Well you could override some of this gems stuff to get things work. If you don't mind having unused columns "uid" and "provider" in your user model and just use something else than its mostly controllers. If you mind (i did) and you want to remove the uid and provider columns, then you have to override alot of stuff because both are kinda hardcoded into the gem. But it's possible.

Still i think doing it yourself is the better solution - this gem does not really do much.

@konpa
Copy link

konpa commented Apr 6, 2016

Yep I know, I customized my User model and I had to override several DeviseAuthToken controller methods to get it working. And even with this, I only managed to get one provider to work at a time. You probably right, I should do it myself but I think I'm too lazy to change my entire auth system (rails api with DeviseAuthToken and the frontend with NgAuthToken)...

@wimhaanstra
Copy link

I am also looking into doing this, and it seems like a bit of work, but allowing my users to log in using multiple providers is a feature I really want.

Note: I only have OAuth login functionality and no email/password option.

What I have added:

  • A UserProvider table, which stores UID's of providers linked to a user. This is the table I will query for UID/Provider matches, and find the right user.

From what I read, I need to override the following:

  • get_resource_from_auth_hash method in OmniauthCallbacksController
  • set_user_by_token method in DeviseTokenAuth::Concerns::SetUserByToken

After I have overriden these controllers, I should be able to remove the uid and provider field from the Users table.

The tokens field on User can still exist I think, because this field stores tokens based on the 'client_id'? Not sure this is wanted though, for example, when you have client_id collisions between services (not likely, but possible).

An option to solve this, would be to override the tokens variable stored on the user and map this to a tokens field on my UserProvider table.

Am I missing something here?

@KRaymundus
Copy link

I am currently trying to implement the same, but with email/password option. Wondering if there are any updates.

@depl0y: Did you map the tokens variable to the UserProvider table? Did you find any other resources to override?

I found this discussion on the topic. Looks like we are implementing "Plan B" here.

@zachfeldman
Copy link
Contributor

Hi there @cars10 and @KRaymundus ,

In an effort to cleanup this project and prioritize a bit, we're marking issues that haven't had any activity in a while with a "close-in-7-days" label. If we don't hear from you in about a week, we'll be closing this issue. Obviously feel free to re-open it at any time if it's the right time or this was done in error!

If you are still having the issue (especially if it's a bug report) please refer to our new Issue Template to provide some more details to help us solve it.

Hope all is well.

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

No branches or pull requests

5 participants