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

Improvement #4

Dombi Attilac95e92acf30e
diff --git a/app/models/user.rb b/app/models/user.rb
index 27d47b8603e..c344e00bd02 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -520,7 +520,7 @@ class User < Principal
end
def allowed_to?(action, context, global: false)
- user_allowed_service.call(action, context, global:).result
+ user_allowed_service.call(action, context, global:)
end
def allowed_to_in_project?(action, project)
diff --git a/app/services/authorization/user_allowed_service.rb b/app/services/authorization/user_allowed_service.rb
index 64283dd704a..7336598d396 100644
--- a/app/services/authorization/user_allowed_service.rb
+++ b/app/services/authorization/user_allowed_service.rb
@@ -45,9 +45,9 @@ class Authorization::UserAllowedService
# or falls back to Non Member / Anonymous permissions depending if the user is logged
def call(action, context, global: false)
if supported_context?(context, global:)
- ServiceResult.success(result: allowed_to?(action, context, global:))
+ allowed_to?(action, context, global:)
else
- ServiceResult.failure(result: false)
+ false
end
end
diff --git a/lib/api/v3/work_packages/work_package_collection_representer.rb b/lib/api/v3/work_packages/work_package_collection_representer.rb
index 682d128c8fe..ea809e7dc72 100644
--- a/lib/api/v3/work_packages/work_package_collection_representer.rb
+++ b/lib/api/v3/work_packages/work_package_collection_representer.rb
@@ -184,7 +184,7 @@ module API
end
def schema_pairs
- represented
+ @schema_pairs ||= represented
.map { |work_package| [work_package.project, work_package.type, work_package.available_custom_fields] }
.uniq
end