mirror of
https://github.com/heartcombo/devise.git
synced 2026-01-10 23:38:10 -05:00
autload Registerable. Extracting default routes and path_names to constants. Fix evals for better debugging and stack trace.
This commit is contained in:
@@ -30,7 +30,7 @@ module Devise
|
||||
:registerable, :rememberable, :timeoutable, :token_authenticatable,
|
||||
:trackable, :validatable]
|
||||
|
||||
# Maps controller names to devise modules
|
||||
# Maps controller names to devise modules.
|
||||
CONTROLLERS = {
|
||||
:sessions => [:authenticatable, :token_authenticatable],
|
||||
:passwords => [:recoverable],
|
||||
@@ -39,12 +39,18 @@ module Devise
|
||||
:unlocks => [:lockable]
|
||||
}
|
||||
|
||||
# Routes for generating url helpers.
|
||||
ROUTES = [:session, :password, :confirmation, :registration, :unlock]
|
||||
|
||||
# Path names used in routes.
|
||||
PATH_NAMES = [:sign_in, :sign_out, :password, :confirmation, :registration, :unlock]
|
||||
|
||||
STRATEGIES = [:rememberable, :token_authenticatable, :authenticatable]
|
||||
|
||||
TRUE_VALUES = [true, 1, '1', 't', 'T', 'true', 'TRUE']
|
||||
|
||||
# Maps the messages types that are used in flash message.
|
||||
FLASH_MESSAGES = [ :unauthenticated, :unconfirmed, :invalid, :invalid_token, :timeout, :inactive, :locked ]
|
||||
FLASH_MESSAGES = [:unauthenticated, :unconfirmed, :invalid, :invalid_token, :timeout, :inactive, :locked]
|
||||
|
||||
# Declare encryptors length which are used in migrations.
|
||||
ENCRYPTORS_LENGTH = {
|
||||
|
||||
@@ -176,7 +176,7 @@ module Devise
|
||||
# before_filter :authenticate_admin! # Tell devise to use :admin map
|
||||
#
|
||||
Devise.mappings.each_key do |mapping|
|
||||
class_eval <<-METHODS, __FILE__, __LINE__
|
||||
class_eval <<-METHODS, __FILE__, __LINE__ + 1
|
||||
def authenticate_#{mapping}!
|
||||
warden.authenticate!(:scope => :#{mapping})
|
||||
end
|
||||
|
||||
@@ -19,7 +19,7 @@ module Devise
|
||||
# Those helpers are added to your ApplicationController.
|
||||
module UrlHelpers
|
||||
|
||||
[:session, :password, :confirmation, :registration, :unlock].each do |module_name|
|
||||
Devise::ROUTES.each do |module_name|
|
||||
[:path, :url].each do |path_or_url|
|
||||
actions = [ nil, :new_ ]
|
||||
actions << :edit_ if module_name == :password
|
||||
@@ -27,9 +27,9 @@ module Devise
|
||||
|
||||
actions.each do |action|
|
||||
class_eval <<-URL_HELPERS
|
||||
def #{action}#{module_name}_#{path_or_url}(resource, *args)
|
||||
resource = Devise::Mapping.find_scope!(resource)
|
||||
send("#{action}\#{resource}_#{module_name}_#{path_or_url}", *args)
|
||||
def #{action}#{module_name}_#{path_or_url}(resource_or_scope, *args)
|
||||
scope = Devise::Mapping.find_scope!(resource_or_scope)
|
||||
send("#{action}\#{scope}_#{module_name}_#{path_or_url}", *args)
|
||||
end
|
||||
URL_HELPERS
|
||||
end
|
||||
|
||||
@@ -115,7 +115,7 @@ module Devise
|
||||
#
|
||||
def self.register(*modules)
|
||||
modules.each do |m|
|
||||
class_eval <<-METHOD, __FILE__, __LINE__
|
||||
class_eval <<-METHOD, __FILE__, __LINE__ + 1
|
||||
def #{m}?
|
||||
self.for.include?(:#{m})
|
||||
end
|
||||
@@ -129,7 +129,7 @@ module Devise
|
||||
# Configure default path names, allowing the user overwrite defaults by
|
||||
# passing a hash in :path_names.
|
||||
def setup_path_names
|
||||
[:sign_in, :sign_out, :password, :confirmation, :registration, :unlock].each do |path_name|
|
||||
Devise::PATH_NAMES.each do |path_name|
|
||||
@path_names[path_name] ||= path_name.to_s
|
||||
end
|
||||
end
|
||||
|
||||
@@ -6,6 +6,7 @@ module Devise
|
||||
autoload :Lockable, 'devise/models/lockable'
|
||||
autoload :Recoverable, 'devise/models/recoverable'
|
||||
autoload :Rememberable, 'devise/models/rememberable'
|
||||
autoload :Registerable, 'devise/models/registerable'
|
||||
autoload :Timeoutable, 'devise/models/timeoutable'
|
||||
autoload :Trackable, 'devise/models/trackable'
|
||||
autoload :Validatable, 'devise/models/validatable'
|
||||
@@ -28,7 +29,7 @@ module Devise
|
||||
#
|
||||
def self.config(mod, *accessors) #:nodoc:
|
||||
accessors.each do |accessor|
|
||||
mod.class_eval <<-METHOD, __FILE__, __LINE__
|
||||
mod.class_eval <<-METHOD, __FILE__, __LINE__ + 1
|
||||
def #{accessor}
|
||||
if defined?(@#{accessor})
|
||||
@#{accessor}
|
||||
@@ -116,4 +117,4 @@ module Devise
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user