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

Extract restricted boards check into a `before_action` hook

Aaron Contrerasf82d2e3588cb
diff --git a/modules/boards/app/controllers/boards/boards_controller.rb b/modules/boards/app/controllers/boards/boards_controller.rb
index ca006393cb3..900e7e412be 100644
--- a/modules/boards/app/controllers/boards/boards_controller.rb
+++ b/modules/boards/app/controllers/boards/boards_controller.rb
@@ -13,6 +13,7 @@ module ::Boards
end
before_action :authorize_global, only: %i[overview new create]
+ before_action :ensure_board_type_not_restricted, only: %i[create]
menu_item :board_view
@@ -37,8 +38,6 @@ module ::Boards
def new; end
def create
- return render_403 if restricted_board_type?
-
service_result = service_call
@board_grid = service_result.result
@@ -64,6 +63,10 @@ module ::Boards
@board_grid = Boards::Grid.new
end
+ def ensure_board_type_not_restricted
+ render_403 if restricted_board_type?
+ end
+
def restricted_board_type?
!EnterpriseToken.allows_to?(:board_view) && board_grid_params[:attribute] != 'basic'
end