diff options
author | Douwe Maan <douwe@selenight.nl> | 2016-04-23 00:19:55 +0300 |
---|---|---|
committer | Douwe Maan <douwe@selenight.nl> | 2016-04-23 00:21:56 +0300 |
commit | d3462e711c0b3cc17ef47e1ffffa6f40f98b5e98 (patch) | |
tree | 84dd1dfaf30c703e2e77a13d0c37a1d8c939d80d /app/controllers/admin/users_controller.rb | |
parent | 80893cad672361e62c0c05c2cf9262209bc54fd2 (diff) |
Fix issue with impersonation
Diffstat (limited to 'app/controllers/admin/users_controller.rb')
-rw-r--r-- | app/controllers/admin/users_controller.rb | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/app/controllers/admin/users_controller.rb b/app/controllers/admin/users_controller.rb index 9abf08d0e19..b8976fa09a9 100644 --- a/app/controllers/admin/users_controller.rb +++ b/app/controllers/admin/users_controller.rb @@ -31,6 +31,22 @@ class Admin::UsersController < Admin::ApplicationController user end + def impersonate + if user.blocked? + flash[:alert] = "You cannot impersonate a blocked user" + + redirect_to admin_user_path(user) + else + session[:impersonator_id] = current_user.id + + warden.set_user(user, scope: :user) + + flash[:alert] = "You are now impersonating #{user.username}" + + redirect_to root_path + end + end + def block if user.block redirect_back_or_admin_user(notice: "Successfully blocked") |