##// END OF EJS Templates
Makes User.find_by_mail case-insensitive (password reminder #2322, repo users mapping)....
Jean-Philippe Lang -
r2120:72d0843c1fef
parent child
Show More
@@ -178,6 +178,11 class User < ActiveRecord::Base
178 token = Token.find_by_action_and_value('autologin', key)
178 token = Token.find_by_action_and_value('autologin', key)
179 token && (token.created_on > Setting.autologin.to_i.day.ago) && token.user.active? ? token.user : nil
179 token && (token.created_on > Setting.autologin.to_i.day.ago) && token.user.active? ? token.user : nil
180 end
180 end
181
182 # Makes find_by_mail case-insensitive
183 def self.find_by_mail(mail)
184 find(:first, :conditions => ["LOWER(mail) = ?", mail.to_s.downcase])
185 end
181
186
182 # Sort users by their display names
187 # Sort users by their display names
183 def <=>(user)
188 def <=>(user)
@@ -44,7 +44,7 class AccountTest < ActionController::IntegrationTest
44 assert_response :success
44 assert_response :success
45 assert_template "account/lost_password"
45 assert_template "account/lost_password"
46
46
47 post "account/lost_password", :mail => 'jsmith@somenet.foo'
47 post "account/lost_password", :mail => 'jSmith@somenet.foo'
48 assert_redirected_to "account/login"
48 assert_redirected_to "account/login"
49
49
50 token = Token.find(:first)
50 token = Token.find(:first)
@@ -158,4 +158,10 class UserTest < Test::Unit::TestCase
158 @jsmith.pref.comments_sorting = 'desc'
158 @jsmith.pref.comments_sorting = 'desc'
159 assert @jsmith.wants_comments_in_reverse_order?
159 assert @jsmith.wants_comments_in_reverse_order?
160 end
160 end
161
162 def test_find_by_mail_should_be_case_insensitive
163 u = User.find_by_mail('JSmith@somenet.foo')
164 assert_not_nil u
165 assert_equal 'jsmith@somenet.foo', u.mail
166 end
161 end
167 end
General Comments 0
You need to be logged in to leave comments. Login now