Module: SolidusSocial

Defined in:
lib/solidus_social/engine.rb,
lib/solidus_social/version.rb,
lib/generators/solidus_social/install/install_generator.rb

Defined Under Namespace

Modules: Generators, VERSION Classes: Engine

Constant Summary collapse

OAUTH_PROVIDERS =
[
%w(Facebook facebook),
%w(Twitter twitter),
%w(Github github),
%w(Google google_oauth2),
%w(Amazon amazon)

Class Method Summary collapse

Class Method Details

.init_provider(provider) ⇒ Object

Setup all OAuth providers


29
30
31
32
33
34
35
36
37
38
39
# File 'lib/solidus_social/engine.rb', line 29

def self.init_provider(provider)
  return unless ActiveRecord::Base.connection.table_exists?('spree_authentication_methods')
  key, secret = nil
  Spree::AuthenticationMethod.where(environment: ::Rails.env).each do |auth_method|
    next unless auth_method.provider == provider
    key = auth_method.api_key
    secret = auth_method.api_secret
    Rails.logger.info("[Spree Social] Loading #{auth_method.provider.capitalize} as authentication source")
  end
  setup_key_for(provider.to_sym, key, secret)
end

.setup_key_for(provider, key, secret) ⇒ Object


41
42
43
44
45
# File 'lib/solidus_social/engine.rb', line 41

def self.setup_key_for(provider, key, secret)
  Devise.setup do |config|
    config.omniauth provider, key, secret, setup: true
  end
end

.versionObject

Returns the version of the currently loaded SolidusSocial as a Gem::Version.


6
7
8
# File 'lib/solidus_social/version.rb', line 6

def version
  Gem::Version.new VERSION::STRING
end