Sha256: 8455776e5aa55a5acd2f1401e68ada22b37aeffea63cbe0793070ad413cae7de

Contents?: true

Size: 1.12 KB

Versions: 2

Compression:

Stored size: 1.12 KB

Contents

# include MuckAuth::Models::MuckAuthentication
module MuckAuth
  module Models
    module MuckAuthentication
      extend ActiveSupport::Concern
    
      included do
        belongs_to :authenticatable, :polymorphic => true        
      end
      
      def access_token
        access_token = OAuth::AccessToken.new(consumer, self.token, self.secret)        
      end
      
      def consumer
        strategy.consumer
      end
      
      def strategy
        strategy_class = OmniAuth::Strategies.const_get("#{OmniAuth::Utils.camelize(self.provider)}")
        strategy_class.new(nil, Secrets.auth_credentials[provider]['key'], Secrets.auth_credentials[provider]['secret'], :scope => Secrets.auth_credentials[provider]['scope'])
      end
        
      module ClassMethods
        
        def all_services
          services = []
          Secrets.auth_credentials.each_key{ |s| services << s }
          services
        end
        
        def unused_services(current_authentications)
          all_services.find_all{ |s| !current_authentications.any?{ |c| c.provider == s } }
        end
        
      end
    
    end 
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
muck-auth-3.5.2 lib/muck-auth/models/authentication.rb
muck-auth-3.5.1 lib/muck-auth/models/authentication.rb