2009-10-18 11:30:32 -04:00
|
|
|
module Devise
|
2009-10-30 06:29:10 -04:00
|
|
|
ALL = [:authenticatable, :confirmable, :recoverable, :rememberable, :validatable].freeze
|
2009-10-18 11:30:32 -04:00
|
|
|
|
|
|
|
# Maps controller names to devise modules
|
|
|
|
CONTROLLERS = {
|
2009-10-30 06:29:10 -04:00
|
|
|
:sessions => :authenticatable,
|
2009-10-18 11:30:32 -04:00
|
|
|
:passwords => :recoverable,
|
|
|
|
:confirmations => :confirmable
|
|
|
|
}.freeze
|
2009-10-20 06:44:21 -04:00
|
|
|
|
2009-11-03 06:35:11 -05:00
|
|
|
STRATEGIES = [:rememberable, :authenticatable].freeze
|
2009-10-20 06:44:21 -04:00
|
|
|
TRUE_VALUES = [true, 1, '1', 't', 'T', 'true', 'TRUE'].freeze
|
2009-10-18 11:30:32 -04:00
|
|
|
|
2009-11-06 11:27:27 -05:00
|
|
|
# Maps the messages types that comes from warden to a flash type.
|
|
|
|
FLASH_MESSAGES = {
|
|
|
|
:unauthenticated => :success,
|
|
|
|
:unconfirmed => :failure
|
|
|
|
}
|
|
|
|
|
2009-11-03 19:34:37 -05:00
|
|
|
# Models configuration
|
|
|
|
mattr_accessor :pepper, :stretches, :remember_for, :confirm_within
|
|
|
|
|
2009-11-06 11:27:27 -05:00
|
|
|
# Mappings
|
|
|
|
mattr_accessor :mappings
|
|
|
|
self.mappings = {}
|
|
|
|
|
2009-11-03 06:35:11 -05:00
|
|
|
class << self
|
|
|
|
# Default way to setup Devise. Run script/generate devise_install to create
|
|
|
|
# a fresh initializer with all configuration values.
|
|
|
|
def setup
|
|
|
|
yield self
|
|
|
|
end
|
|
|
|
|
2009-11-06 06:40:38 -05:00
|
|
|
def mail_sender=(value) #:nodoc:
|
|
|
|
ActiveSupport::Deprecation.warn "Devise.mail_sender= is deprecated, use Devise.mailer_sender instead"
|
|
|
|
DeviseMailer.sender = value
|
|
|
|
end
|
|
|
|
|
2009-11-03 06:35:11 -05:00
|
|
|
# Sets the sender in DeviseMailer.
|
2009-11-06 06:40:38 -05:00
|
|
|
def mailer_sender=(value)
|
2009-11-03 06:35:11 -05:00
|
|
|
DeviseMailer.sender = value
|
|
|
|
end
|
2009-11-06 06:40:38 -05:00
|
|
|
alias :sender= :mailer_sender=
|
2009-10-30 19:51:50 -04:00
|
|
|
|
2009-11-03 06:35:11 -05:00
|
|
|
# Sets warden configuration using a block that will be invoked on warden
|
|
|
|
# initialization.
|
|
|
|
#
|
|
|
|
# Devise.initialize do |config|
|
|
|
|
# config.confirm_within = 2.days
|
|
|
|
#
|
|
|
|
# config.warden do |manager|
|
|
|
|
# # Configure warden to use other strategies, like oauth.
|
|
|
|
# manager.oauth(:twitter)
|
|
|
|
# end
|
|
|
|
# end
|
|
|
|
def warden(&block)
|
|
|
|
@warden_config = block
|
|
|
|
end
|
|
|
|
|
|
|
|
# A method used internally to setup warden manager from the Rails initialize
|
|
|
|
# block.
|
|
|
|
def configure_warden_manager(manager) #:nodoc:
|
|
|
|
manager.default_strategies *Devise::STRATEGIES
|
|
|
|
manager.failure_app = Devise::Failure
|
|
|
|
manager.silence_missing_strategies!
|
|
|
|
|
|
|
|
# If the user provided a warden hook, call it now.
|
|
|
|
@warden_config.try :call, manager
|
|
|
|
end
|
|
|
|
end
|
2009-10-11 07:15:48 -04:00
|
|
|
end
|
2009-10-20 22:12:21 -04:00
|
|
|
|
|
|
|
require 'devise/warden'
|
2009-11-03 06:35:11 -05:00
|
|
|
require 'devise/rails'
|