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

remove methods rendered superfluous by using default auth methods

ulfertsd3e81b257b57
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
index 99b472d8364..a6d29d50bda 100644
--- a/app/controllers/application_controller.rb
+++ b/app/controllers/application_controller.rb
@@ -458,23 +458,6 @@ class ApplicationController < ActionController::Base
render_404
end
- # Make sure that the user is a member of the project (or admin) if project is private
- # used as a before_action for actions that do not require any particular permission
- # on the project.
- def check_project_privacy
- if @project && @project.active?
- if @project.public? || User.current.member_of?(@project) || User.current.admin?
- true
- else
- User.current.logged? ? render_403 : require_login
- end
- else
- @project = nil
- render_404
- false
- end
- end
-
def back_url
params[:back_url] || request.env["HTTP_REFERER"]
end
diff --git a/app/controllers/news_controller.rb b/app/controllers/news_controller.rb
index 3455f2d1324..a124aac4715 100644
--- a/app/controllers/news_controller.rb
+++ b/app/controllers/news_controller.rb
@@ -112,13 +112,4 @@ class NewsController < ApplicationController
rescue ActiveRecord::RecordNotFound
render_404
end
-
- def find_optional_project
- return true unless params[:project_id]
-
- @project = Project.find(params[:project_id])
- authorize
- rescue ActiveRecord::RecordNotFound
- render_404
- end
end
diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb
index 3d09898e072..04503237f79 100644
--- a/app/controllers/projects_controller.rb
+++ b/app/controllers/projects_controller.rb
@@ -104,15 +104,6 @@ class ProjectsController < ApplicationController
project.project_storages.any?(&:project_folder_automatic?)
end
- def find_optional_project
- return true unless params[:id]
-
- @project = Project.find(params[:id])
- authorize
- rescue ActiveRecord::RecordNotFound
- render_404
- end
-
def hide_project_in_layout
@project = nil
end
diff --git a/app/controllers/search_controller.rb b/app/controllers/search_controller.rb
index 2b526534d47..a4b26fde274 100644
--- a/app/controllers/search_controller.rb
+++ b/app/controllers/search_controller.rb
@@ -62,15 +62,6 @@ class SearchController < ApplicationController
end
end
- def find_optional_project
- return true unless params[:project_id]
-
- @project = Project.find(params[:project_id])
- check_project_privacy
- rescue ActiveRecord::RecordNotFound
- render_404
- end
-
def limit_results_first_page
@pagination_previous_date = @results[0].event_datetime if offset && @results[0]
diff --git a/modules/budgets/app/controllers/budgets_controller.rb b/modules/budgets/app/controllers/budgets_controller.rb
index a6edf12954f..2f2ee53bffc 100644
--- a/modules/budgets/app/controllers/budgets_controller.rb
+++ b/modules/budgets/app/controllers/budgets_controller.rb
@@ -219,12 +219,6 @@ class BudgetsController < ApplicationController
render_404
end
- def find_project
- @project = Project.find(params[:project_id])
- rescue ActiveRecord::RecordNotFound
- render_404
- end
-
def find_optional_project
@project = Project.find(params[:project_id]) if params[:project_id].present?
rescue ActiveRecord::RecordNotFound
diff --git a/modules/costs/app/controllers/costlog_controller.rb b/modules/costs/app/controllers/costlog_controller.rb
index a1d5e792271..f4c3bc6eba1 100644
--- a/modules/costs/app/controllers/costlog_controller.rb
+++ b/modules/costs/app/controllers/costlog_controller.rb
@@ -115,22 +115,6 @@ class CostlogController < ApplicationController
render_404
end
- def find_optional_project
- if params[:work_package_id].present?
- @work_package = WorkPackage.find(params[:work_package_id])
- @project = @work_package.project
- elsif params[:work_package_id].present?
- @work_package = WorkPackage.find(params[:work_package_id])
- @project = @work_package.project
- elsif params[:project_id].present?
- @project = Project.find(params[:project_id])
- end
-
- if params[:cost_type_id].present?
- @cost_type = CostType.find(params[:cost_type_id])
- end
- end
-
def find_associated_objects
user_id = cost_entry_params.delete(:user_id)
@user = if @cost_entry.present? && @cost_entry.user_id == user_id