1
0
Fork 0
mirror of https://github.com/heartcombo/devise.git synced 2022-11-09 12:18:31 -05:00
heartcombo--devise/lib/devise.rb

75 lines
2.1 KiB
Ruby
Raw Normal View History

module Devise
ALL = [:authenticatable, :confirmable, :recoverable, :rememberable, :validatable].freeze
# Maps controller names to devise modules
CONTROLLERS = {
:sessions => :authenticatable,
:passwords => :recoverable,
:confirmations => :confirmable
}.freeze
2009-10-20 06:44:21 -04:00
STRATEGIES = [:rememberable, :authenticatable].freeze
2009-10-20 06:44:21 -04:00
TRUE_VALUES = [true, 1, '1', 't', 'T', 'true', 'TRUE'].freeze
# Maps the messages types that comes from warden to a flash type.
FLASH_MESSAGES = {
:unauthenticated => :success,
:unconfirmed => :failure
}
# Models configuration
mattr_accessor :pepper, :stretches, :remember_for, :confirm_within
# Mappings
mattr_accessor :mappings
self.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
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
# Sets the sender in DeviseMailer.
2009-11-06 06:40:38 -05:00
def mailer_sender=(value)
DeviseMailer.sender = value
end
2009-11-06 06:40:38 -05:00
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
# 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
2009-10-20 22:12:21 -04:00
require 'devise/warden'
require 'devise/rails'