From 63c92189a88a6c03f7e59d30b7564970a8e18bfd Mon Sep 17 00:00:00 2001 From: Gregor Schmidt Date: Thu, 10 Feb 2011 18:47:26 +0100 Subject: [PATCH 1/2] relaxing the test for mysql to make it work for mysql2 adapter --- app/models/user.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/user.rb b/app/models/user.rb index d7b1bfb6..d2d68520 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -279,7 +279,7 @@ class User < Principal # version. Exact matches will be given priority. def self.find_by_login(login) # force string comparison to be case sensitive on MySQL - type_cast = (ActiveRecord::Base.connection.adapter_name == 'MySQL') ? 'BINARY' : '' + type_cast = (ActiveRecord::Base.connection.adapter_name =~ /mysql/) ? 'BINARY' : '' # First look for an exact match user = first(:conditions => ["#{type_cast} login = ?", login]) From 49b789e1055264cec5c18b0377640bb83050653b Mon Sep 17 00:00:00 2001 From: Gregor Schmidt Date: Thu, 10 Feb 2011 18:54:53 +0100 Subject: [PATCH 2/2] making comparison case-insensitive --- app/models/user.rb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/app/models/user.rb b/app/models/user.rb index d2d68520..60339a19 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -279,8 +279,7 @@ class User < Principal # version. Exact matches will be given priority. def self.find_by_login(login) # force string comparison to be case sensitive on MySQL - type_cast = (ActiveRecord::Base.connection.adapter_name =~ /mysql/) ? 'BINARY' : '' - + type_cast = (ActiveRecord::Base.connection.adapter_name =~ /mysql/i) ? 'BINARY' : '' # First look for an exact match user = first(:conditions => ["#{type_cast} login = ?", login]) # Fail over to case-insensitive if none was found