Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

Fix and simplify UserEntityRolesQuery

Klaus Zandersefcf2e1b3696
diff --git a/app/services/authorization/user_entity_roles_query.rb b/app/services/authorization/user_entity_roles_query.rb
index efe4052c605..04a3a614d94 100644
--- a/app/services/authorization/user_entity_roles_query.rb
+++ b/app/services/authorization/user_entity_roles_query.rb
@@ -32,10 +32,12 @@ class Authorization::UserEntityRolesQuery < Authorization::UserRolesQuery
end
transformations.register users_members_join, :entity_restriction do |statement, _, entity|
- statement
+ statement = statement
.and(members_table[:entity_type].eq(entity.class.to_s))
.and(members_table[:entity_id].eq(entity.id))
- statement.and(members_table[:project_id].eq(entity.project.id)) if entity.respond_to?(:project)
+ statement = statement.and(members_table[:project_id].eq(entity.project_id)) if entity.respond_to?(:project_id)
+
+ statement
end
end