From 883fcb89ee25649f75e94173a9a46cf5ff8af757 Mon Sep 17 00:00:00 2001 From: Marius Balteanu Date: Sun, 27 Mar 2022 21:29:05 +0000 Subject: Include roles of built-in "Non member users" and "Anonymous users" members when user is not a member of the project. This fixes #34029. git-svn-id: https://svn.redmine.org/redmine/trunk@21502 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/models/user.rb | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/app/models/user.rb b/app/models/user.rb index 7ead1f8cb..1a4022c39 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -622,6 +622,15 @@ class User < Principal Role.joins(members: :project). where(["#{Project.table_name}.status <> ?", Project::STATUS_ARCHIVED]). where(Member.arel_table[:user_id].eq(id)).distinct + + if @roles.blank? + group_class = anonymous? ? GroupAnonymous : GroupNonMember + @roles = Role.joins(members: :project). + where(["#{Project.table_name}.status <> ? AND #{Project.table_name}.is_public = ?", Project::STATUS_ARCHIVED, true]). + where(Member.arel_table[:user_id].eq(group_class.first.id)).distinct + end + + @roles end # Returns the user's bult-in role -- cgit v1.2.3