Sha256: 5b1d4483f7f153808ed1c0891ef961493f8ef999f31bff66215b73233f029ea6
Contents?: true
Size: 1.66 KB
Versions: 2
Compression:
Stored size: 1.66 KB
Contents
require 'spree_core' require 'spree_auth' require 'omniauth/oauth' require "spree_social_hooks" module SpreeSocial PROVIDERS = [ "facebook", "twitter", "github" ] class Engine < Rails::Engine def self.activate Dir.glob(File.join(File.dirname(__FILE__), "../app/**/*_decorator*.rb")) do |c| Rails.env.production? ? require(c) : load(c) end end config.to_prepare &method(:activate).to_proc end # We are setting these providers up regardless # This way we can update them when and where necessary def self.init_provider(provider) key, secret = nil AuthenticationMethod.where(:environment => ::Rails.env).each do |user| if user.preferred_provider == provider key = user.preferred_api_key secret = user.preferred_api_secret end end if self.table_exists?("authentication_methods") # See Below for explanation self.setup_key_for(provider.to_sym, key, secret) end def self.setup_key_for(provider, key, secret) Devise.setup do |oa| oa.omniauth provider.to_sym, key, secret end end # Coming soon to a server near you: no restart to get new keys setup #def self.reset_key_for(provider, *args) # puts "ARGS: #{args}" # Devise.omniauth_configs[provider] = Devise::OmniAuth::Config.new(provider, args) # #oa_updated_provider # #Devise.omniauth_configs.merge!(oa_updated_provider) # puts "OmniAuth #{provider}: #{Devise.omniauth_configs[provider.to_sym].inspect}" #end private # Have to test for this cause Rails migrations and initial setups will fail def self.table_exists?(name) ActiveRecord::Base.connection.tables.include?(name) end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
spree_social-1.0.2 | lib/spree_social.rb |
spree_social-1.0.1 | lib/spree_social.rb |