FIX: lowercase username for add/rem group members

This fix searches for users based on the downcased username so that if
you pass in usernames to add/remove from a group and you don't have the
casing just right it will still find the correct users.

I updated the tests to add a username that has a mix of upper and
lowercase letters to verify this functionality.
This commit is contained in:
Blake Erickson
2018-10-18 13:17:24 -06:00
parent 3973823a33
commit 93485facaf
2 changed files with 3 additions and 3 deletions

View File

@ -484,7 +484,7 @@ class GroupsController < ApplicationController
def users_from_params
if params[:usernames].present?
users = User.where(username: params[:usernames].split(","))
users = User.where(username_lower: params[:usernames].split(",").map(&:downcase))
raise Discourse::InvalidParameters.new(:usernames) if users.blank?
elsif params[:user_ids].present?
users = User.where(id: params[:user_ids].split(","))