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

simplify code

ulferts06334ea33a75
diff --git a/app/services/authorization/user_allowed_service.rb b/app/services/authorization/user_allowed_service.rb
index 7480028051b..4b8138e73c9 100644
--- a/app/services/authorization/user_allowed_service.rb
+++ b/app/services/authorization/user_allowed_service.rb
@@ -93,10 +93,9 @@ class Authorization::UserAllowedService
has_authorized_role?(action, project)
end
+ # Authorize if user is authorized on every element of the array
def allowed_to_in_all_projects?(action, projects)
- projects = projects.to_a
- # Authorize if user is authorized on every element of the array
- projects.present? && projects.all? do |project|
+ Array(projects).all? do |project|
allowed_to?(action, project)
end
end
@@ -140,7 +139,7 @@ class Authorization::UserAllowedService
def normalize_action(action)
if action.is_a?(Hash) && action[:controller] && action[:controller].to_s.starts_with?('/')
action = action.dup
- action[:controller] = action[:controller][1..-1]
+ action[:controller] = action[:controller][1..]
end
action