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
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
[#59985] add validation check to custom field controller
Eric Schubert482b7d7d27b3
diff --git a/app/controllers/custom_fields_controller.rb b/app/controllers/custom_fields_controller.rbindex 2beb4cfd0ff..c280ec2dfeb 100644--- a/app/controllers/custom_fields_controller.rb+++ b/app/controllers/custom_fields_controller.rb@@ -30,14 +30,17 @@ class CustomFieldsController < ApplicationControllerinclude CustomFields::SharedActions # share logic with ProjectCustomFieldsControlllerlayout "admin"+ # rubocop:disable Rails/LexicallyScopedActionFilterbefore_action :require_adminbefore_action :find_custom_field, only: %i(edit update destroy delete_option reorder_alphabetical)before_action :prepare_custom_option_position, only: %i(update create)before_action :find_custom_option, only: :delete_option+ before_action :validate_enterprise_token, only: %i(create)+ # rubocop:enable Rails/LexicallyScopedActionFilterdef index# loading wp cfs exclicity to allow for eager loading- @custom_fields_by_type = CustomField.all+ @custom_fields_by_type = CustomField.where.not(type: ["WorkPackageCustomField", "ProjectCustomField"]).group_by { |f| f.class.name }@@ -64,6 +67,12 @@ class CustomFieldsController < ApplicationControllerfalseend+ def validate_enterprise_token+ if params.dig(:custom_field, :field_format) == "hierarchy" && !EnterpriseToken.allows_to?(:custom_field_hierarchies)+ render_403+ end+ end+def find_custom_field@custom_field = CustomField.find(params[:id])rescue ActiveRecord::RecordNotFound