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

rename method for clarity

ulferts563229dc3efa
diff --git a/app/controllers/activities_controller.rb b/app/controllers/activities_controller.rb
index 8093becbaf1..1c66dec3058 100644
--- a/app/controllers/activities_controller.rb
+++ b/app/controllers/activities_controller.rb
@@ -30,7 +30,7 @@ class ActivitiesController < ApplicationController
include Layout
menu_item :activity
- before_action :authorize_in_optional_project,
+ before_action :load_and_authorize_in_optional_project,
:verify_activities_module_activated,
:determine_subprojects,
:determine_author,
diff --git a/app/controllers/concerns/accounts/authorization.rb b/app/controllers/concerns/accounts/authorization.rb
index afb6f4d6e3d..fd5620b6f76 100644
--- a/app/controllers/concerns/accounts/authorization.rb
+++ b/app/controllers/concerns/accounts/authorization.rb
@@ -31,7 +31,7 @@
module Accounts::Authorization
extend ActiveSupport::Concern
- METHODS_ENFORCING_AUTHORIZATION = %i[require_admin authorize authorize_global authorize_in_optional_project].freeze
+ METHODS_ENFORCING_AUTHORIZATION = %i[require_admin authorize authorize_global load_and_authorize_in_optional_project].freeze
included do
class_attribute :authorization_ensured,
@@ -77,7 +77,7 @@ module Accounts::Authorization
end
# Find a project based on params[:project_id]
- def authorize_in_optional_project
+ def load_and_authorize_in_optional_project
@project = Project.find(params[:project_id]) if params[:project_id].present?
do_authorize({ controller: params[:controller], action: params[:action] }, global: params[:project_id].blank?)
diff --git a/app/controllers/journals_controller.rb b/app/controllers/journals_controller.rb
index 31e664f0e60..5fbf7e6766f 100644
--- a/app/controllers/journals_controller.rb
+++ b/app/controllers/journals_controller.rb
@@ -29,7 +29,7 @@
#++
class JournalsController < ApplicationController
- before_action :authorize_in_optional_project, only: [:index]
+ before_action :load_and_authorize_in_optional_project, only: [:index]
before_action :find_journal,
:ensure_permitted,
only: [:diff]
diff --git a/app/controllers/news_controller.rb b/app/controllers/news_controller.rb
index a124aac4715..27e9d57ef12 100644
--- a/app/controllers/news_controller.rb
+++ b/app/controllers/news_controller.rb
@@ -36,7 +36,7 @@ class NewsController < ApplicationController
before_action :find_project_from_association, except: %i[new create index]
before_action :find_project, only: %i[new create]
before_action :authorize, except: [:index]
- before_action :authorize_in_optional_project, only: [:index]
+ before_action :load_and_authorize_in_optional_project, only: [:index]
accept_key_auth :index
def index
diff --git a/app/controllers/search_controller.rb b/app/controllers/search_controller.rb
index a4b26fde274..e29eeb94e44 100644
--- a/app/controllers/search_controller.rb
+++ b/app/controllers/search_controller.rb
@@ -29,7 +29,7 @@
class SearchController < ApplicationController
include Layout
- before_action :authorize_in_optional_project,
+ before_action :load_and_authorize_in_optional_project,
:prepare_tokens
LIMIT = 10
diff --git a/app/controllers/work_packages_controller.rb b/app/controllers/work_packages_controller.rb
index f66dcea7711..d67001318a2 100644
--- a/app/controllers/work_packages_controller.rb
+++ b/app/controllers/work_packages_controller.rb
@@ -36,7 +36,7 @@ class WorkPackagesController < ApplicationController
before_action :authorize_on_work_package,
:project, only: :show
- before_action :authorize_in_optional_project,
+ before_action :load_and_authorize_in_optional_project,
:check_allowed_export,
:protect_from_unauthorized_export, only: :index
authorization_checked! only: %i[index show]
diff --git a/modules/boards/app/controllers/boards/boards_controller.rb b/modules/boards/app/controllers/boards/boards_controller.rb
index 07e9f85d6b8..165b522196d 100644
--- a/modules/boards/app/controllers/boards/boards_controller.rb
+++ b/modules/boards/app/controllers/boards/boards_controller.rb
@@ -2,7 +2,7 @@ module ::Boards
class BoardsController < BaseController
include Layout
- before_action :authorize_in_optional_project
+ before_action :load_and_authorize_in_optional_project
# The boards permission alone does not suffice
# to view work packages
diff --git a/modules/calendar/app/controllers/calendar/calendars_controller.rb b/modules/calendar/app/controllers/calendar/calendars_controller.rb
index 2145a5b76e8..9e6a2aa0758 100644
--- a/modules/calendar/app/controllers/calendar/calendars_controller.rb
+++ b/modules/calendar/app/controllers/calendar/calendars_controller.rb
@@ -28,7 +28,7 @@
module ::Calendar
class CalendarsController < ApplicationController
- before_action :authorize_in_optional_project
+ before_action :load_and_authorize_in_optional_project
before_action :build_calendar_view, only: %i[new]
before_action :authorize, except: %i[index new create]
before_action :authorize_global, only: %i[index new create]
diff --git a/modules/gantt/app/controllers/gantt/gantt_controller.rb b/modules/gantt/app/controllers/gantt/gantt_controller.rb
index 69289d26747..3b75bcfbc59 100644
--- a/modules/gantt/app/controllers/gantt/gantt_controller.rb
+++ b/modules/gantt/app/controllers/gantt/gantt_controller.rb
@@ -6,7 +6,7 @@ module ::Gantt
accept_key_auth :index
- before_action :authorize_in_optional_project, :protect_from_unauthorized_export, only: :index
+ before_action :load_and_authorize_in_optional_project, :protect_from_unauthorized_export, only: :index
before_action :load_and_validate_query, only: :index, unless: -> { request.format.html? }
diff --git a/modules/gantt/app/controllers/gantt/menus_controller.rb b/modules/gantt/app/controllers/gantt/menus_controller.rb
index 3e6cae9bdd8..0708b6a95ca 100644
--- a/modules/gantt/app/controllers/gantt/menus_controller.rb
+++ b/modules/gantt/app/controllers/gantt/menus_controller.rb
@@ -27,7 +27,7 @@
# ++
module Gantt
class MenusController < ApplicationController
- before_action :authorize_in_optional_project
+ before_action :load_and_authorize_in_optional_project
def show
@sidebar_menu_items = menu_items
diff --git a/modules/meeting/app/controllers/meetings_controller.rb b/modules/meeting/app/controllers/meetings_controller.rb
index 07b9a2dbc7a..733f4947029 100644
--- a/modules/meeting/app/controllers/meetings_controller.rb
+++ b/modules/meeting/app/controllers/meetings_controller.rb
@@ -28,7 +28,7 @@
class MeetingsController < ApplicationController
around_action :set_time_zone
- before_action :authorize_in_optional_project, only: %i[index new show create history]
+ before_action :load_and_authorize_in_optional_project, only: %i[index new show create history]
before_action :verify_activities_module_activated, only: %i[history]
before_action :determine_date_range, only: %i[history]
before_action :determine_author, only: %i[history]
diff --git a/modules/reporting/app/controllers/cost_reports_controller.rb b/modules/reporting/app/controllers/cost_reports_controller.rb
index d333cf6430f..81880f56d24 100644
--- a/modules/reporting/app/controllers/cost_reports_controller.rb
+++ b/modules/reporting/app/controllers/cost_reports_controller.rb
@@ -40,7 +40,7 @@ class CostReportsController < ApplicationController
before_action :check_cache
before_action :load_all
- before_action :authorize_in_optional_project
+ before_action :load_and_authorize_in_optional_project
before_action :find_optional_user
include Layout
diff --git a/modules/team_planner/app/controllers/team_planner/team_planner_controller.rb b/modules/team_planner/app/controllers/team_planner/team_planner_controller.rb
index c720fd2ba2a..a2e08ebef42 100644
--- a/modules/team_planner/app/controllers/team_planner/team_planner_controller.rb
+++ b/modules/team_planner/app/controllers/team_planner/team_planner_controller.rb
@@ -2,7 +2,7 @@ module ::TeamPlanner
class TeamPlannerController < BaseController
include EnterpriseTrialHelper
include Layout
- before_action :authorize_in_optional_project
+ before_action :load_and_authorize_in_optional_project
before_action :build_plan_view, only: %i[new]
before_action :require_ee_token, except: %i[upsale]
before_action :find_plan_view, only: %i[destroy]
diff --git a/spec/controllers/concerns/authorization_spec.rb b/spec/controllers/concerns/authorization_spec.rb
index 61c110c90f4..45296d7eaf8 100644
--- a/spec/controllers/concerns/authorization_spec.rb
+++ b/spec/controllers/concerns/authorization_spec.rb
@@ -46,7 +46,7 @@ RSpec.describe ApplicationController, "enforcement of authorization" do # ruboco
def authorize; end
- def authorize_in_optional_project; end
+ def load_and_authorize_in_optional_project; end
def other_before_action; end
end
@@ -110,9 +110,9 @@ RSpec.describe ApplicationController, "enforcement of authorization" do # ruboco
it_behaves_like "succeeds"
end
- context "with authorization checked with authorize_in_optional_project" do
+ context "with authorization checked with load_and_authorize_in_optional_project" do
controller do
- before_action :authorize_in_optional_project
+ before_action :load_and_authorize_in_optional_project
include controller_setup
end