ruby-on-railsoauthspreeclass-evalspree-auth-devise

How to remove OAUTH_PROVIDERS in Spree Social plugin


I've been reading through the SpreeSocial documentation here. I can't figure out how to remove providers through the config. I've tried to just pop the most recent provider off off of the list but that's not working.

  SpreeSocial::OAUTH_PROVIDERS.pop

I managed to make the 'Sign in with LinkedIn' appear in the views, but I'd like to remove the 'Sign in with Google+' link.

SpreeSocial::OAUTH_PROVIDERS << ['LinkedIn', 'linkedin', 'true']
SpreeSocial.init_provider('linkedin')

If I want to open up the classes in SpreeSocial with .class_eval (I assume that this may help me edit which providers are available), where would I place those files so that they would autoload, or where would I need to configure them? Pretty new to Spree/Rails so not too familiar with configurations and initializers. Thanks for the help!

I'd like to be able to call .class_eval on the SpreeSocial Module here


Solution

  • SpreeSocial::OAUTH_PROVIDERS is going to be redefined when the code initializes the application so just using pop won't be sufficient. Since SpreeSocial is a module not a class you'll need to either:

    1) Use a module_eval not a class_eval to redefine the SpreeSocial::OAUTH_PROVIDERS

    SpreeSocial.module_eval do OAUTH_PROVIDERS = [ %w(Facebook facebook true), %w(Twitter twitter false), %w(Github github false), %w(Amazon amazon false) ] end

    or

    2) You could override the methods that determine active authentication methods to not return google: https://github.com/spree-contrib/spree_social/blob/master/app/models/spree/authentication_method.rb#L4-L12