lib/devise/models/authenticatable.rb in devise-3.1.2 vs lib/devise/models/authenticatable.rb in devise-3.2.0
- old
+ new
@@ -27,13 +27,11 @@
#
# * +params_authenticatable+: if this model allows authentication through request params. By default true.
# It also accepts an array specifying the strategies that should allow params authentication.
#
# * +skip_session_storage+: By default Devise will store the user in session.
- # You can skip storage for http and token auth by appending values to array:
- # :skip_session_storage => [:token_auth] or :skip_session_storage => [:http_auth, :token_auth],
- # by default is set to :skip_session_storage => [:http_auth].
+ # By default is set to :skip_session_storage => [:http_auth].
#
# == active_for_authentication?
#
# After authenticating a user and in each request, Devise checks if your model is active by
# calling model.active_for_authentication?. This method is overwritten by other devise modules. For instance,
@@ -174,26 +172,27 @@
def send_devise_notification(notification, *args)
devise_mailer.send(notification, self, *args).deliver
end
def downcase_keys
- self.class.case_insensitive_keys.each { |k| apply_to_attribute_or_variable(k, :downcase!) }
+ self.class.case_insensitive_keys.each { |k| apply_to_attribute_or_variable(k, :downcase) }
end
def strip_whitespace
- self.class.strip_whitespace_keys.each { |k| apply_to_attribute_or_variable(k, :strip!) }
+ self.class.strip_whitespace_keys.each { |k| apply_to_attribute_or_variable(k, :strip) }
end
def apply_to_attribute_or_variable(attr, method)
if self[attr]
- self[attr].try(method)
+ self[attr] = self[attr].try(method)
# Use respond_to? here to avoid a regression where globally
# configured strip_whitespace_keys or case_insensitive_keys were
- # attempting to strip! or downcase! when a model didn't have the
+ # attempting to strip or downcase when a model didn't have the
# globally configured key.
- elsif respond_to?(attr)
- send(attr).try(method)
+ elsif respond_to?(attr) && respond_to?("#{attr}=")
+ new_value = send(attr).try(method)
+ send("#{attr}=", new_value)
end
end
module ClassMethods
Devise::Models.config(self, :authentication_keys, :request_keys, :strip_whitespace_keys,