summaryrefslogtreecommitdiff
path: root/app/controllers
diff options
context:
space:
mode:
authorAndrew Tomaka <atomaka@gmail.com>2015-12-01 23:40:24 -0500
committerAndrew Tomaka <atomaka@gmail.com>2015-12-02 08:07:29 -0500
commitdaca985a6e75d6f43c5cc5b487a0942d5bf93f68 (patch)
tree579e8734014953e8aaa1c784cd4a857e50c6ed79 /app/controllers
parent09e712c0fb721059e4b2619eb9fc104257fc492d (diff)
downloadgitlab-ce-daca985a6e75d6f43c5cc5b487a0942d5bf93f68.tar.gz
Prevent impersonation if blocked
Diffstat (limited to 'app/controllers')
-rw-r--r--app/controllers/admin/impersonation_controller.rb16
1 files changed, 11 insertions, 5 deletions
diff --git a/app/controllers/admin/impersonation_controller.rb b/app/controllers/admin/impersonation_controller.rb
index 0382402afa6..102dd437402 100644
--- a/app/controllers/admin/impersonation_controller.rb
+++ b/app/controllers/admin/impersonation_controller.rb
@@ -5,14 +5,20 @@ class Admin::ImpersonationController < Admin::ApplicationController
before_action :authorize_impersonator!
def create
- session[:impersonator_id] = current_user.username
- session[:impersonator_return_to] = request.env['HTTP_REFERER']
+ if @user.blocked?
+ flash[:alert] = "You cannot impersonate a blocked user"
- warden.set_user(user, scope: 'user')
+ redirect_to admin_user_path(@user)
+ else
+ session[:impersonator_id] = current_user.username
+ session[:impersonator_return_to] = request.env['HTTP_REFERER']
+
+ warden.set_user(user, scope: 'user')
- flash[:alert] = "You are impersonating #{user.username}."
+ flash[:alert] = "You are impersonating #{user.username}."
- redirect_to root_path
+ redirect_to root_path
+ end
end
def destroy