Module: Devise

Defined in:
lib/devise.rb,
lib/devise/models.rb,
lib/devise/failure.rb,
lib/devise/mapping.rb,
lib/devise/version.rb,
lib/devise/orm/base.rb,
lib/devise/migrations.rb,
lib/devise/encryptors/sha1.rb,
lib/devise/strategies/base.rb,
lib/devise/orm/mongo_mapper.rb,
lib/devise/encryptors/sha512.rb,
lib/devise/orm/active_record.rb,
lib/devise/models/confirmable.rb,
lib/devise/models/recoverable.rb,
lib/devise/models/validatable.rb,
lib/devise/controllers/filters.rb,
lib/devise/controllers/helpers.rb,
lib/devise/models/rememberable.rb,
lib/devise/models/authenticatable.rb,
lib/devise/controllers/url_helpers.rb,
lib/devise/middlewares/rememberable.rb,
lib/devise/encryptors/clearance_sha1.rb,
lib/devise/strategies/authenticatable.rb,
lib/devise/encryptors/authlogic_sha512.rb,
lib/devise/encryptors/restful_authentication_sha1.rb

Defined Under Namespace

Modules: Controllers, Encryptors, Failure, Middlewares, Migrations, Models, Orm, Strategies Classes: Mapping

Constant Summary collapse

ALL =
[:authenticatable, :confirmable, :recoverable, :rememberable, :validatable].freeze
CONTROLLERS =

Maps controller names to devise modules

{
  :sessions => :authenticatable,
  :passwords => :recoverable,
  :confirmations => :confirmable
}.freeze
STRATEGIES =
[:authenticatable].freeze
TRUE_VALUES =
[true, 1, '1', 't', 'T', 'true', 'TRUE'].freeze
FLASH_MESSAGES =

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.

{
  :unauthenticated => :success,
  :unconfirmed => :failure
}
ENCRYPTORS_LENGTH =

Declare encryptors length which are used in migrations.

{
  :sha1   => 40,
  :sha512 => 128,
  :clearance_sha1 => 40,
  :restful_authentication_sha1 => 40,
  :authlogic_sha512 => 128
}
VERSION =
"0.4.3.1".freeze
@@pepper =
nil
@@stretches =
10
@@remember_for =
2.weeks
@@confirm_within =
0.days
@@encryptor =
::Devise::Encryptors::Sha1
@@mappings =
{}
@@orm =
'active_record'

Class Method Summary collapse

Class Method Details

.configure_warden_manager(manager) ⇒ Object

A method used internally to setup warden manager from the Rails initialize block.



104
105
106
107
108
109
110
111
# File 'lib/devise.rb', line 104

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

.default_url_options(&block) ⇒ Object

Configure default url options to be used within Devise and ActionController.



98
99
100
# File 'lib/devise.rb', line 98

def default_url_options(&block)
  Devise::Mapping.metaclass.send :define_method, :default_url_options, &block
end

.encryptor=(value) ⇒ Object

Used to define the password encryption algorithm.



47
48
49
50
51
52
53
# File 'lib/devise.rb', line 47

def self.encryptor=(value)
  @@encryptor = if value.is_a?(Symbol)
    ::Devise::Encryptors.const_get(value.to_s.classify)
  else
    value
  end
end

.mail_sender=(value) ⇒ Object

:nodoc:



71
72
73
74
# File 'lib/devise.rb', line 71

def mail_sender=(value) #:nodoc:
  ActiveSupport::Deprecation.warn "Devise.mail_sender= is deprecated, use Devise.mailer_sender instead"
  DeviseMailer.sender = value
end

.mailer_sender=(value) ⇒ Object Also known as: sender=

Sets the sender in DeviseMailer.



77
78
79
# File 'lib/devise.rb', line 77

def mailer_sender=(value)
  DeviseMailer.sender = value
end

.model_ormObject

The class to call with orm define



115
116
117
# File 'lib/devise.rb', line 115

def model_orm
  @@model_orm ||= "Devise::Orm::#{@@orm.camelize}".constantize
end

.setup {|_self| ... } ⇒ Object

Default way to setup Devise. Run script/generate devise_install to create a fresh initializer with all configuration values.

Yields:

  • (_self)

Yield Parameters:

  • _self (Devise)

    the object that the method was called on



67
68
69
# File 'lib/devise.rb', line 67

def setup
  yield self
end

.warden(&block) ⇒ Object

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


93
94
95
# File 'lib/devise.rb', line 93

def warden(&block)
  @warden_config = block
end