Multiple Oauth at the same time in a Rails application?

My ultimate goal is for users to have multiple third-party authentications at the same time.

I am currently using Devise to create users. Users can register via email or facebook or google, and it works. But now, after they have already registered, I need them to also check, say, youtube or soundcloud. Thus, the user was created using development, but I also need them to check other things.

Since Devise hogs omniauth is for my purposes, I cannot use omniauth on the side.

As I can see, I have three options:

  • Try creating monkeypatch and ask him to allow multiple authentications for the same user at the same time.
  • Do it manually manually on the side adjacent to the current project implementation
  • Hunk and do something else

I would really appreciate any advice or other options.

+5
source share
2 answers

monkeypatch

--- oauth

class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController

  def facebook
    # handle if already a twitter user
    # handle if a new user
    # use the `sign_in user` to sign_in the user
  end

  def twitter
    # handle if already a facebook user
    # handle if a new user
  end
end

devise_for :user, 
         :controllers => {
           :omniauth_callbacks => "users/omniauth_callbacks"
         }
+1

All Articles