summaryrefslogtreecommitdiff
path: root/app/controllers
diff options
context:
space:
mode:
Diffstat (limited to 'app/controllers')
-rw-r--r--app/controllers/admin/users_controller.rb2
-rw-r--r--app/controllers/concerns/project_unauthorized.rb2
-rw-r--r--app/controllers/concerns/routable_actions.rb20
-rw-r--r--app/controllers/groups/application_controller.rb2
-rw-r--r--app/controllers/groups/clusters/applications_controller.rb2
-rw-r--r--app/controllers/groups/clusters/integrations_controller.rb2
-rw-r--r--app/controllers/groups/clusters_controller.rb2
-rw-r--r--app/controllers/profiles/groups_controller.rb2
-rw-r--r--app/controllers/projects/application_controller.rb2
-rw-r--r--app/controllers/projects/clusters/applications_controller.rb2
-rw-r--r--app/controllers/projects/clusters/integrations_controller.rb2
-rw-r--r--app/controllers/projects/clusters_controller.rb2
-rw-r--r--app/controllers/users_controller.rb2
13 files changed, 22 insertions, 22 deletions
diff --git a/app/controllers/admin/users_controller.rb b/app/controllers/admin/users_controller.rb
index 700acc46d8d..145b4d10b16 100644
--- a/app/controllers/admin/users_controller.rb
+++ b/app/controllers/admin/users_controller.rb
@@ -304,7 +304,7 @@ class Admin::UsersController < Admin::ApplicationController
end
def user
- @user ||= find_routable!(User, params[:id])
+ @user ||= find_routable!(User, params[:id], request.path_info)
end
def build_canonical_path(user)
diff --git a/app/controllers/concerns/project_unauthorized.rb b/app/controllers/concerns/project_unauthorized.rb
index 7238840440f..b58f6589f9b 100644
--- a/app/controllers/concerns/project_unauthorized.rb
+++ b/app/controllers/concerns/project_unauthorized.rb
@@ -3,7 +3,7 @@
module ProjectUnauthorized
module ControllerActions
def self.on_routable_not_found
- lambda do |routable|
+ lambda do |routable, path_info|
return unless routable.is_a?(Project)
label = routable.external_authorization_classification_label
diff --git a/app/controllers/concerns/routable_actions.rb b/app/controllers/concerns/routable_actions.rb
index 7257378f465..57108369c64 100644
--- a/app/controllers/concerns/routable_actions.rb
+++ b/app/controllers/concerns/routable_actions.rb
@@ -3,13 +3,13 @@
module RoutableActions
extend ActiveSupport::Concern
- def find_routable!(routable_klass, requested_full_path, extra_authorization_proc: nil)
- routable = routable_klass.find_by_full_path(requested_full_path, follow_redirects: request.get?)
+ def find_routable!(routable_klass, routable_full_path, path_info, extra_authorization_proc: nil)
+ routable = routable_klass.find_by_full_path(routable_full_path, follow_redirects: request.get?)
if routable_authorized?(routable, extra_authorization_proc)
- ensure_canonical_path(routable, requested_full_path)
+ ensure_canonical_path(routable, routable_full_path)
routable
else
- perform_not_found_actions(routable, not_found_actions)
+ perform_not_found_actions(routable, not_found_actions, path_info)
route_not_found unless performed?
@@ -21,11 +21,11 @@ module RoutableActions
[ProjectUnauthorized::ControllerActions.on_routable_not_found]
end
- def perform_not_found_actions(routable, actions)
+ def perform_not_found_actions(routable, actions, path_info)
actions.each do |action|
break if performed?
- instance_exec(routable, &action)
+ instance_exec(routable, path_info, &action)
end
end
@@ -42,13 +42,13 @@ module RoutableActions
end
end
- def ensure_canonical_path(routable, requested_full_path)
+ def ensure_canonical_path(routable, routable_full_path)
return unless request.get?
canonical_path = routable.full_path
- if canonical_path != requested_full_path
- if !request.xhr? && request.format.html? && canonical_path.casecmp(requested_full_path) != 0
- flash[:notice] = "#{routable.class.to_s.titleize} '#{requested_full_path}' was moved to '#{canonical_path}'. Please update any links and bookmarks that may still have the old path."
+ if canonical_path != routable_full_path
+ if !request.xhr? && request.format.html? && canonical_path.casecmp(routable_full_path) != 0
+ flash[:notice] = "#{routable.class.to_s.titleize} '#{routable_full_path}' was moved to '#{canonical_path}'. Please update any links and bookmarks that may still have the old path."
end
redirect_to build_canonical_path(routable), status: :moved_permanently
diff --git a/app/controllers/groups/application_controller.rb b/app/controllers/groups/application_controller.rb
index f6c71ac8087..69081835c4d 100644
--- a/app/controllers/groups/application_controller.rb
+++ b/app/controllers/groups/application_controller.rb
@@ -24,7 +24,7 @@ class Groups::ApplicationController < ApplicationController
end
def group
- @group ||= find_routable!(Group, params[:group_id] || params[:id])
+ @group ||= find_routable!(Group, params[:group_id] || params[:id], request.path_info)
end
def group_projects
diff --git a/app/controllers/groups/clusters/applications_controller.rb b/app/controllers/groups/clusters/applications_controller.rb
index 8dd8a01cf40..ce6fda4143c 100644
--- a/app/controllers/groups/clusters/applications_controller.rb
+++ b/app/controllers/groups/clusters/applications_controller.rb
@@ -13,6 +13,6 @@ class Groups::Clusters::ApplicationsController < Clusters::ApplicationsControlle
end
def group
- @group ||= find_routable!(Group, params[:group_id] || params[:id])
+ @group ||= find_routable!(Group, params[:group_id] || params[:id], request.path_info)
end
end
diff --git a/app/controllers/groups/clusters/integrations_controller.rb b/app/controllers/groups/clusters/integrations_controller.rb
index e8c8a14c164..61b308f7d1b 100644
--- a/app/controllers/groups/clusters/integrations_controller.rb
+++ b/app/controllers/groups/clusters/integrations_controller.rb
@@ -13,6 +13,6 @@ class Groups::Clusters::IntegrationsController < Clusters::IntegrationsControlle
end
def group
- @group ||= find_routable!(Group, params[:group_id] || params[:id])
+ @group ||= find_routable!(Group, params[:group_id] || params[:id], request.path_info)
end
end
diff --git a/app/controllers/groups/clusters_controller.rb b/app/controllers/groups/clusters_controller.rb
index 33bfc24885f..6f3eecf8296 100644
--- a/app/controllers/groups/clusters_controller.rb
+++ b/app/controllers/groups/clusters_controller.rb
@@ -15,7 +15,7 @@ class Groups::ClustersController < Clusters::ClustersController
end
def group
- @group ||= find_routable!(Group, params[:group_id] || params[:id])
+ @group ||= find_routable!(Group, params[:group_id] || params[:id], request.path_info)
end
def metrics_dashboard_params
diff --git a/app/controllers/profiles/groups_controller.rb b/app/controllers/profiles/groups_controller.rb
index e76ee0a6cea..2571e92e071 100644
--- a/app/controllers/profiles/groups_controller.rb
+++ b/app/controllers/profiles/groups_controller.rb
@@ -6,7 +6,7 @@ class Profiles::GroupsController < Profiles::ApplicationController
feature_category :users
def update
- group = find_routable!(Group, params[:id])
+ group = find_routable!(Group, params[:id], request.path_info)
notification_setting = current_user.notification_settings_for(group)
if notification_setting.update(update_params)
diff --git a/app/controllers/projects/application_controller.rb b/app/controllers/projects/application_controller.rb
index ca2692438e8..cf2ecb0673e 100644
--- a/app/controllers/projects/application_controller.rb
+++ b/app/controllers/projects/application_controller.rb
@@ -26,7 +26,7 @@ class Projects::ApplicationController < ApplicationController
path = File.join(params[:namespace_id], params[:project_id] || params[:id])
auth_proc = ->(project) { !project.pending_delete? }
- @project = find_routable!(Project, path, extra_authorization_proc: auth_proc)
+ @project = find_routable!(Project, path, request.path_info, extra_authorization_proc: auth_proc)
end
def build_canonical_path(project)
diff --git a/app/controllers/projects/clusters/applications_controller.rb b/app/controllers/projects/clusters/applications_controller.rb
index 2a04b007304..6c5778124e8 100644
--- a/app/controllers/projects/clusters/applications_controller.rb
+++ b/app/controllers/projects/clusters/applications_controller.rb
@@ -10,6 +10,6 @@ class Projects::Clusters::ApplicationsController < Clusters::ApplicationsControl
end
def project
- @project ||= find_routable!(Project, File.join(params[:namespace_id], params[:project_id]))
+ @project ||= find_routable!(Project, File.join(params[:namespace_id], params[:project_id]), request.path_info)
end
end
diff --git a/app/controllers/projects/clusters/integrations_controller.rb b/app/controllers/projects/clusters/integrations_controller.rb
index 94b8dd653e6..eed6c1dccc4 100644
--- a/app/controllers/projects/clusters/integrations_controller.rb
+++ b/app/controllers/projects/clusters/integrations_controller.rb
@@ -10,6 +10,6 @@ class Projects::Clusters::IntegrationsController < ::Clusters::IntegrationsContr
end
def project
- @project ||= find_routable!(Project, File.join(params[:namespace_id], params[:project_id]))
+ @project ||= find_routable!(Project, File.join(params[:namespace_id], params[:project_id]), request.path_info)
end
end
diff --git a/app/controllers/projects/clusters_controller.rb b/app/controllers/projects/clusters_controller.rb
index 8acf5235c1a..0aef497d28d 100644
--- a/app/controllers/projects/clusters_controller.rb
+++ b/app/controllers/projects/clusters_controller.rb
@@ -17,7 +17,7 @@ class Projects::ClustersController < Clusters::ClustersController
end
def project
- @project ||= find_routable!(Project, File.join(params[:namespace_id], params[:project_id]))
+ @project ||= find_routable!(Project, File.join(params[:namespace_id], params[:project_id]), request.path_info)
end
def repository
diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb
index 7282fc26121..1b927afdcf5 100644
--- a/app/controllers/users_controller.rb
+++ b/app/controllers/users_controller.rb
@@ -172,7 +172,7 @@ class UsersController < ApplicationController
private
def user
- @user ||= find_routable!(User, params[:username])
+ @user ||= find_routable!(User, params[:username], request.path_info)
end
def personal_projects