From 8df66f9276eaf4bcb403563d527a639d18d5b260 Mon Sep 17 00:00:00 2001 From: Jonathan Rochkind Date: Mon, 14 Nov 2016 10:56:04 -0500 Subject: [PATCH] Stop mutating username to downcase In my rails5 app, the email is ending up frozen, not sure why, but it causes an exception trying to mutate frozen string. But of course Sorcery ought not to be mutating the email input regardless. --- lib/sorcery/model.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/sorcery/model.rb b/lib/sorcery/model.rb index b4b90095..71b879c4 100644 --- a/lib/sorcery/model.rb +++ b/lib/sorcery/model.rb @@ -87,7 +87,7 @@ def authenticate(*credentials) return false if credentials[0].blank? if @sorcery_config.downcase_username_before_authenticating - credentials[0].downcase! + credentials[0] = credentials[0].downcase end user = sorcery_adapter.find_by_credentials(credentials) @@ -117,7 +117,7 @@ def set_encryption_attributes() @sorcery_config.encryption_provider.stretches = @sorcery_config.stretches if @sorcery_config.encryption_provider.respond_to?(:stretches) && @sorcery_config.stretches @sorcery_config.encryption_provider.join_token = @sorcery_config.salt_join_token if @sorcery_config.encryption_provider.respond_to?(:join_token) && @sorcery_config.salt_join_token end - + def add_config_inheritance self.class_eval do def self.inherited(subclass) @@ -148,7 +148,7 @@ def external? # Calls the configured encryption provider to compare the supplied password with the encrypted one. def valid_password?(pass) - _crypted = self.send(sorcery_config.crypted_password_attribute_name) + _crypted = self.send(sorcery_config.crypted_password_attribute_name) return _crypted == pass if sorcery_config.encryption_provider.nil? _salt = self.send(sorcery_config.salt_attribute_name) unless sorcery_config.salt_attribute_name.nil?