mirror of
https://github.com/heartcombo/devise.git
synced 2026-04-06 03:01:21 -04:00
Initial routes and module setup.
This commit is contained in:
@@ -161,14 +161,38 @@ module Devise
|
||||
mattr_accessor :navigational_formats
|
||||
@@navigational_formats = [:html]
|
||||
|
||||
# When set to true, signing out an user signs out all other scopes.
|
||||
mattr_accessor :sign_out_all_scopes
|
||||
@@sign_out_all_scopes = false
|
||||
|
||||
# Oauth providers
|
||||
mattr_accessor :oauth_providers
|
||||
@@oauth_providers = []
|
||||
|
||||
# PRIVATE CONFIGURATION
|
||||
|
||||
# Oauth configurations.
|
||||
mattr_reader :oauth_configs
|
||||
@@oauth_configs = {}
|
||||
|
||||
# Private methods to interface with Warden.
|
||||
mattr_accessor :warden_config
|
||||
@@warden_config = nil
|
||||
@@warden_config_block = nil
|
||||
|
||||
# When set to true, signing out an user signs out all other scopes.
|
||||
mattr_accessor :sign_out_all_scopes
|
||||
@@sign_out_all_scopes = false
|
||||
# Specify an oauth provider.
|
||||
#
|
||||
# config.oauth :github, APP_ID, APP_SECRET,
|
||||
# :site => 'https://github.com/',
|
||||
# :authorize_path => '/login/oauth/authorize',
|
||||
# :access_token_path => '/login/oauth/access_token',
|
||||
# :scope => %w(user public_repo)
|
||||
#
|
||||
def self.oauth(provider, *args)
|
||||
@@oauth_providers << provider
|
||||
@@oauth_providers.uniq!
|
||||
@@oauth_configs[provider] = Devise::OAuth::Config.new(*args)
|
||||
end
|
||||
|
||||
def self.use_default_scope=(*)
|
||||
ActiveSupport::Deprecation.warn "config.use_default_scope is deprecated and removed from Devise. " <<
|
||||
@@ -209,7 +233,6 @@ module Devise
|
||||
# +model+ - String representing the load path to a custom *model* for this module (to autoload.)
|
||||
# +controller+ - Symbol representing the name of an exisiting or custom *controller* for this module.
|
||||
# +route+ - Symbol representing the named *route* helper for this module.
|
||||
# +flash+ - Symbol representing the *flash messages* used by this helper.
|
||||
# +strategy+ - Symbol representing if this module got a custom *strategy*.
|
||||
#
|
||||
# All values, except :model, accept also a boolean and will have the same name as the given module
|
||||
@@ -243,8 +266,8 @@ module Devise
|
||||
end
|
||||
|
||||
if options[:model]
|
||||
model_path = (options[:model] == true ? "devise/models/#{module_name}" : options[:model])
|
||||
Devise::Models.send(:autoload, module_name.to_s.camelize.to_sym, model_path)
|
||||
path = (options[:model] == true ? "devise/models/#{module_name}" : options[:model])
|
||||
Devise::Models.send(:autoload, module_name.to_s.camelize.to_sym, path)
|
||||
end
|
||||
|
||||
Devise::Mapping.add_module module_name
|
||||
|
||||
11
lib/devise/models/oauthable.rb
Normal file
11
lib/devise/models/oauthable.rb
Normal file
@@ -0,0 +1,11 @@
|
||||
module Devise
|
||||
module Models
|
||||
module Oauthable
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
module ClassMethods
|
||||
Devise::Models.config(self, :oauth_providers)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -8,7 +8,10 @@ Devise.with_options :model => true do |d|
|
||||
s.add_module :rememberable
|
||||
end
|
||||
|
||||
# Misc after
|
||||
# Other authentications
|
||||
d.add_module :oauthable, :controller => :oauth_callbacks, :route => :oauth_callback
|
||||
|
||||
# Misc after
|
||||
d.add_module :recoverable, :controller => :passwords, :route => :password
|
||||
d.add_module :registerable, :controller => :registrations, :route => :registration
|
||||
d.add_module :validatable
|
||||
|
||||
@@ -231,6 +231,11 @@ module ActionDispatch::Routing
|
||||
:path_names => { :new => mapping.path_names[:sign_up] }, :controller => controllers[:registrations]
|
||||
end
|
||||
|
||||
def devise_oauth_callback(mapping, controllers) #:nodoc:
|
||||
get "/oauth/:action/callback", :action => Regexp.union(mapping.to.oauth_providers.map(&:to_s)),
|
||||
:to => controllers[:oauth_callbacks], :as => :outh_callback
|
||||
end
|
||||
|
||||
def with_devise_exclusive_scope(new_path, new_as) #:nodoc:
|
||||
old_as, old_path, old_module = @scope[:as], @scope[:path], @scope[:module]
|
||||
@scope[:as], @scope[:path], @scope[:module] = new_as, new_path, nil
|
||||
|
||||
Reference in New Issue
Block a user