mirror of
https://github.com/heartcombo/devise.git
synced 2022-11-09 12:18:31 -05:00
first attempt
This commit is contained in:
parent
67645c68f7
commit
94c666e439
3 changed files with 15 additions and 1 deletions
|
@ -67,6 +67,10 @@ module Devise
|
|||
mattr_accessor :request_keys
|
||||
@@request_keys = []
|
||||
|
||||
# If authentication keys should be case-insensitive by default.
|
||||
mattr_accessor :case_insensitive_keys
|
||||
@@case_insensitive_keys = false
|
||||
|
||||
# If http authentication is enabled by default.
|
||||
mattr_accessor :http_authenticatable
|
||||
@@http_authenticatable = false
|
||||
|
|
|
@ -77,7 +77,7 @@ module Devise
|
|||
end
|
||||
|
||||
module ClassMethods
|
||||
Devise::Models.config(self, :authentication_keys, :request_keys, :http_authenticatable, :params_authenticatable)
|
||||
Devise::Models.config(self, :authentication_keys, :request_keys, :case_insensitive_keys, :http_authenticatable, :params_authenticatable)
|
||||
|
||||
def params_authenticatable?(strategy)
|
||||
params_authenticatable.is_a?(Array) ?
|
||||
|
@ -100,6 +100,9 @@ module Devise
|
|||
# end
|
||||
#
|
||||
def find_for_authentication(conditions)
|
||||
if case_insensitive_keys
|
||||
authentication_keys.each { |k| conditions[k].try(:downcase!) }
|
||||
end
|
||||
to_adapter.find_first(conditions)
|
||||
end
|
||||
|
||||
|
@ -110,6 +113,10 @@ module Devise
|
|||
|
||||
# Find an initialize a group of attributes based on a list of required attributes.
|
||||
def find_or_initialize_with_errors(required_attributes, attributes, error=:invalid) #:nodoc:
|
||||
if case_insensitive_keys
|
||||
authentication_keys.each { |k| attributes[k].try(:downcase!) }
|
||||
end
|
||||
|
||||
attributes = attributes.slice(*required_attributes)
|
||||
attributes.delete_if { |key, value| value.blank? }
|
||||
|
||||
|
|
|
@ -31,6 +31,9 @@ Devise.setup do |config|
|
|||
# The same considerations mentioned for authentication_keys also apply to request_keys.
|
||||
# config.request_keys = []
|
||||
|
||||
# If authentication keys should be case-insensitive. False by default.
|
||||
# config.case_insensitive_keys = false
|
||||
|
||||
# Tell if authentication through request.params is enabled. True by default.
|
||||
# config.params_authenticatable = true
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue