diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-08-17 17:15:21 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-08-17 17:15:21 +0000 |
commit | 76044a792737e4b966be861b68947d289539c66e (patch) | |
tree | 6355ac9d8b54beb5e6e0fd8fe6d28a464f8a5395 /app/controllers/concerns | |
parent | f63ce3000c16c04b7a7d5200c5da7c07b9af0cf2 (diff) | |
download | gitlab-ce-76044a792737e4b966be861b68947d289539c66e.tar.gz |
Add latest changes from gitlab-org/gitlab@14-1-stable-ee
Diffstat (limited to 'app/controllers/concerns')
-rw-r--r-- | app/controllers/concerns/project_unauthorized.rb | 2 | ||||
-rw-r--r-- | app/controllers/concerns/routable_actions.rb | 20 |
2 files changed, 11 insertions, 11 deletions
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 |