From d2f64ee9288a3be2ec29e42aaf796559d3dd6b4b Mon Sep 17 00:00:00 2001 From: Marius Balteanu Date: Tue, 1 Feb 2022 20:11:56 +0000 Subject: Fix autocomplete for users fails with 403 error when there are multiple objects from different projects (#36446). Patch by Dmitry Makurin. git-svn-id: http://svn.redmine.org/redmine/trunk@21394 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/controllers/watchers_controller.rb | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'app/controllers') diff --git a/app/controllers/watchers_controller.rb b/app/controllers/watchers_controller.rb index 97afffe01..9170acb34 100644 --- a/app/controllers/watchers_controller.rb +++ b/app/controllers/watchers_controller.rb @@ -134,8 +134,12 @@ class WatchersController < ApplicationController def users_for_new_watcher scope = nil - if params[:q].blank? && @project.present? - scope = @project.principals.assignable_watchers + if params[:q].blank? + if @project.present? + scope = @project.principals.assignable_watchers + elsif @projects.present? && @projects.size > 1 + scope = Principal.joins(:members).where(:members => { :project_id => @projects }).assignable_watchers.distinct + end else scope = Principal.assignable_watchers.limit(100) end -- cgit v1.2.3