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.
This commit is contained in:
Tom Hughes 2011-12-13 17:42:42 +00:00
parent 3f5374901e
commit 7b01a8ae82

View file

@ -201,7 +201,15 @@ class UserController < ApplicationController
@title = t 'user.lost_password.title' @title = t 'user.lost_password.title'
if params[:user] and params[:user][:email] 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 if user
token = user.tokens.create token = user.tokens.create