diff --git a/app/controllers/finish_installation_controller.rb b/app/controllers/finish_installation_controller.rb index 848aa127f81..4640677ebca 100644 --- a/app/controllers/finish_installation_controller.rb +++ b/app/controllers/finish_installation_controller.rb @@ -15,7 +15,7 @@ class FinishInstallationController < ApplicationController email = params[:email].strip raise Discourse::InvalidParameters.new unless @allowed_emails.include?(email) - return redirect_confirm(email) if UserEmail.exists?(email: email) + return redirect_confirm(email) if UserEmail.where("lower(email) = ?", email).exists? @user.email = email @user.username = params[:username] diff --git a/app/models/user.rb b/app/models/user.rb index 0ac14d77a19..818053f66d7 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -134,7 +134,9 @@ class User < ActiveRecord::Base # set to true to optimize creation and save for imports attr_accessor :import_mode - scope :with_email, ->(email) { joins(:user_emails).where(user_emails: { email: email }) } + scope :with_email, ->(email) do + joins(:user_emails).where("lower(user_emails.email) = ?", email) + end scope :human_users, -> { where('users.id > 0') } diff --git a/lib/admin_user_index_query.rb b/lib/admin_user_index_query.rb index fd3da2a23af..ed2a0b5f55f 100644 --- a/lib/admin_user_index_query.rb +++ b/lib/admin_user_index_query.rb @@ -104,7 +104,7 @@ class AdminUserIndexQuery def filter_by_user_with_bypass(filter) if filter =~ /.+@.+/ # probably an email so try the bypass - user_id = UserEmail.where(email: filter.downcase).pluck(:user_id).first + user_id = UserEmail.where("lower(email) = ?", filter.downcase).pluck(:user_id).first if user_id return @query.where('users.id = ?', user_id) end