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

Ensure user config is not overwriten by default config.

This commit is contained in:
José Valim 2009-11-09 22:00:44 -02:00
parent 05678e773f
commit 80699c58b4
5 changed files with 23 additions and 11 deletions

View file

@ -12,17 +12,31 @@ module Devise
TRUE_VALUES = [true, 1, '1', 't', 'T', 'true', 'TRUE'].freeze TRUE_VALUES = [true, 1, '1', 't', 'T', 'true', 'TRUE'].freeze
# Maps the messages types that comes from warden to a flash type. # 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 = { FLASH_MESSAGES = {
:unauthenticated => :success, :unauthenticated => :success,
:unconfirmed => :failure :unconfirmed => :failure
} }
# Models configuration # Used to encrypt password. Please generate one with rake secret
mattr_accessor :pepper, :stretches, :remember_for, :confirm_within mattr_accessor :pepper
@@pepper = nil
# 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
# Mappings # Store scopes mappings.
mattr_accessor :mappings mattr_accessor :mappings
self.mappings = {} @@mappings = {}
class << self class << self
# Default way to setup Devise. Run script/generate devise_install to create # Default way to setup Devise. Run script/generate devise_install to create
@ -76,4 +90,4 @@ module Devise
end end
require 'devise/warden' require 'devise/warden'
require 'devise/rails' require 'devise/rails'

View file

@ -16,9 +16,7 @@ module Devise
# To add the class methods you need to have a module ClassMethods defined # To add the class methods you need to have a module ClassMethods defined
# inside the given class. # inside the given class.
# #
def self.config(mod, accessor, default=nil) #:nodoc: def self.config(mod, accessor) #:nodoc:
Devise.send :"#{accessor}=", default
mod.class_eval <<-METHOD, __FILE__, __LINE__ mod.class_eval <<-METHOD, __FILE__, __LINE__
def #{accessor} def #{accessor}
self.class.#{accessor} self.class.#{accessor}

View file

@ -91,7 +91,7 @@ module Devise
end end
Devise::Models.config(self, :pepper) Devise::Models.config(self, :pepper)
Devise::Models.config(self, :stretches, 10) Devise::Models.config(self, :stretches)
end end
end end
end end

View file

@ -150,7 +150,7 @@ module Devise
end end
end end
Devise::Models.config(self, :confirm_within, 0.days) Devise::Models.config(self, :confirm_within)
end end
end end
end end

View file

@ -89,7 +89,7 @@ module Devise
end end
end end
Devise::Models.config(self, :remember_for, 2.weeks) Devise::Models.config(self, :remember_for)
end end
end end
end end