Module: Sorcery::Controller::Submodules::Oauth

Defined in:
lib/sorcery/controller/submodules/oauth.rb,
lib/sorcery.rb,
lib/sorcery/controller/submodules/oauth/oauth1.rb,
lib/sorcery/controller/submodules/oauth/oauth2.rb,
lib/sorcery/controller/submodules/oauth/providers/twitter.rb,
lib/sorcery/controller/submodules/oauth/providers/facebook.rb

Overview

This submodule helps you login users from OAuth providers such as Twitter. This is the controller part which handles the http requests and tokens passed between the app and the provider. For more configuration options see Sorcery::Model::Oauth.

Defined Under Namespace

Modules: InstanceMethods, Oauth1, Oauth2, Providers

Class Method Summary collapse

Class Method Details

.included(base) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/sorcery/controller/submodules/oauth.rb', line 8

def self.included(base)
  base.send(:include, InstanceMethods)
  Config.module_eval do
    class << self
      attr_reader :oauth_providers                           # oauth providers like twitter.
                                  
      def merge_oauth_defaults!
        @defaults.merge!(:@oauth_providers => [])
      end
      
      def oauth_providers=(providers)
        providers.each do |provider|
          include Providers.const_get(provider.to_s.split("_").map {|p| p.capitalize}.join(""))
        end
      end
    end
    merge_oauth_defaults!
  end
end