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

allowed_in_any_entity? returned false when no WP existed

Klaus Zanders1699ec75362c
diff --git a/app/services/authorization/user_permissible_service.rb b/app/services/authorization/user_permissible_service.rb
index 134b5872a1a..94bf483299c 100644
--- a/app/services/authorization/user_permissible_service.rb
+++ b/app/services/authorization/user_permissible_service.rb
@@ -51,6 +51,12 @@ module Authorization
perms = contextual_permissions(permission, context_name(entity_class))
return true if admin_and_all_granted_to_admin?(perms)
+ # Short circuit, when the user is permitted in the project. This is for the edge case
+ # when the user has permissions in the project, but not work package exists yet, the other
+ # query below would return false in those cases.
+ return true if in_project && allowed_in_single_project?(perms, in_project)
+ return true if !in_project && allowed_in_any_project?(perms)
+
# entity_class.allowed_to will also check whether the user has the permission via a membership in the project.
allowed_scope = entity_class.allowed_to(user, perms)