From: Tom Hughes Date: Tue, 13 Dec 2011 17:42:42 +0000 (+0000) Subject: Look up email addresses case insensitively for password resets X-Git-Tag: live~5929 X-Git-Url: https://git.openstreetmap.org/rails.git/commitdiff_plain/7b01a8ae82873ecef35679b387a9d29a49c0a3b2 Look up email addresses case insensitively for password resets If the email address entered is not found then try a case insensitive lookup, and if that finds a single result then use it. --- diff --git a/app/controllers/user_controller.rb b/app/controllers/user_controller.rb index ce0122957..c9983cc85 100644 --- a/app/controllers/user_controller.rb +++ b/app/controllers/user_controller.rb @@ -201,7 +201,15 @@ class UserController < ApplicationController @title = t 'user.lost_password.title' if params[:user] and params[:user][:email] - user = User.visible.where(:email => params[:user][:email]).first + user = User.visible.find_by_email(params[:user][:email]) + + if user.nil? + users = User.visible.where("LOWER(email) = LOWER(?)", params[:user][:email]) + + if users.count == 1 + user = users.first + end + end if user token = user.tokens.create