module Devise ALL = [:authenticatable, :confirmable, :recoverable, :rememberable, :validatable].freeze # Maps controller names to devise modules CONTROLLERS = { :sessions => :authenticatable, :passwords => :recoverable, :confirmations => :confirmable }.freeze STRATEGIES = [:rememberable, :authenticatable].freeze TRUE_VALUES = [true, 1, '1', 't', 'T', 'true', 'TRUE'].freeze # Maps the messages types that comes from warden to a flash type. # This hash is not frozen, so you can add your messages as well. FLASH_MESSAGES = { :unauthenticated => :success, :unconfirmed => :failure } # Used to encrypt password. Please generate one with rake secret mattr_accessor :pepper @@pepper = nil # Used to define the password encryption algorithm mattr_accessor :encryptor @@encryptor = ::Devise::Encryptors::Sha1 # The number of times to encrypt password. mattr_accessor :stretches @@stretches = 10 # Time interval where the remember me token is valid. mattr_accessor :remember_for @@remember_for = 2.weeks # Time interval you can access your account before confirming your account. mattr_accessor :confirm_within @@confirm_within = 0.days # Store scopes mappings. mattr_accessor :mappings @@mappings = {} 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 def mail_sender=(value) #:nodoc: ActiveSupport::Deprecation.warn "Devise.mail_sender= is deprecated, use Devise.mailer_sender instead" DeviseMailer.sender = value end # Sets the sender in DeviseMailer. def mailer_sender=(value) DeviseMailer.sender = value end alias :sender= :mailer_sender= # 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 # Configure default url options to be used within Devise and ActionController. def default_url_options(&block) Devise::Mapping.metaclass.send :define_method, :default_url_options, &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 end require 'devise/warden' require 'devise/rails'