diff options
author | Michael Kozono <mkozono@gmail.com> | 2017-05-01 23:46:30 +0300 |
---|---|---|
committer | Michael Kozono <mkozono@gmail.com> | 2017-05-05 22:11:57 +0300 |
commit | 7d02bcd2e0165a90a9f2c1edb34b064ff76afd69 (patch) | |
tree | 3b74cbbf74fca3b36effa5ea4b33d8bd29e22f73 /app/controllers/users_controller.rb | |
parent | f4a2dfb46f168d3fd7309aca8631cf680456fa82 (diff) |
Redirect from redirect routes to canonical routes
Diffstat (limited to 'app/controllers/users_controller.rb')
-rw-r--r-- | app/controllers/users_controller.rb | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index a452bbba422..6b6b3b20a8d 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -1,7 +1,9 @@ class UsersController < ApplicationController + include RoutableActions + skip_before_action :authenticate_user! before_action :user, except: [:exists] - before_action :authorize_read_user!, only: [:show] + before_action :authorize_read_user!, except: [:exists] def show respond_to do |format| @@ -92,11 +94,15 @@ class UsersController < ApplicationController private def authorize_read_user! - render_404 unless can?(current_user, :read_user, user) + if can?(current_user, :read_user, user) + ensure_canonical_path(user.namespace, params[:username]) + else + render_404 + end end def user - @user ||= User.find_by_username!(params[:username]) + @user ||= User.find_by_full_path(params[:username], follow_redirects: true) end def contributed_projects |