summaryrefslogtreecommitdiff
path: root/app/controllers/groups
diff options
context:
space:
mode:
authorMichael Kozono <mkozono@gmail.com>2017-05-01 13:46:30 -0700
committerMichael Kozono <mkozono@gmail.com>2017-05-05 12:11:57 -0700
commit7d02bcd2e0165a90a9f2c1edb34b064ff76afd69 (patch)
tree3b74cbbf74fca3b36effa5ea4b33d8bd29e22f73 /app/controllers/groups
parentf4a2dfb46f168d3fd7309aca8631cf680456fa82 (diff)
downloadgitlab-ce-7d02bcd2e0165a90a9f2c1edb34b064ff76afd69.tar.gz
Redirect from redirect routes to canonical routes
Diffstat (limited to 'app/controllers/groups')
-rw-r--r--app/controllers/groups/application_controller.rb21
1 files changed, 12 insertions, 9 deletions
diff --git a/app/controllers/groups/application_controller.rb b/app/controllers/groups/application_controller.rb
index 29ffaeb19c1..209d8b1a08a 100644
--- a/app/controllers/groups/application_controller.rb
+++ b/app/controllers/groups/application_controller.rb
@@ -1,4 +1,6 @@
class Groups::ApplicationController < ApplicationController
+ include RoutableActions
+
layout 'group'
skip_before_action :authenticate_user!
@@ -8,18 +10,15 @@ class Groups::ApplicationController < ApplicationController
def group
unless @group
- id = params[:group_id] || params[:id]
- @group = Group.find_by_full_path(id)
- @group_merge_requests = MergeRequestsFinder.new(current_user, group_id: @group.id).execute
+ given_path = params[:group_id] || params[:id]
+ @group = Group.find_by_full_path(given_path, follow_redirects: request.get?)
- unless @group && can?(current_user, :read_group, @group)
+ if @group && can?(current_user, :read_group, @group)
+ ensure_canonical_path(@group, given_path)
+ else
@group = nil
- if current_user.nil?
- authenticate_user!
- else
- render_404
- end
+ route_not_found
end
end
@@ -30,6 +29,10 @@ class Groups::ApplicationController < ApplicationController
@projects ||= GroupProjectsFinder.new(group: group, current_user: current_user).execute
end
+ def group_merge_requests
+ @group_merge_requests = MergeRequestsFinder.new(current_user, group_id: @group.id).execute
+ end
+
def authorize_admin_group!
unless can?(current_user, :admin_group, group)
return render_404