debian-mirror-gitlab/app/controllers/admin/impersonations_controller.rb

27 lines
722 B
Ruby
Raw Normal View History

2016-06-02 11:05:42 +05:30
class Admin::ImpersonationsController < Admin::ApplicationController
skip_before_action :authenticate_admin!
before_action :authenticate_impersonator!
def destroy
original_user = current_user
warden.set_user(impersonator, scope: :user)
2016-09-13 17:45:13 +05:30
Gitlab::AppLogger.info("User #{impersonator.username} has stopped impersonating #{original_user.username}")
2016-06-02 11:05:42 +05:30
session[:impersonator_id] = nil
2017-09-10 17:25:29 +05:30
redirect_to admin_user_path(original_user), status: 302
2016-06-02 11:05:42 +05:30
end
private
def impersonator
@impersonator ||= User.find(session[:impersonator_id]) if session[:impersonator_id]
end
def authenticate_impersonator!
2017-08-17 22:00:37 +05:30
render_404 unless impersonator && impersonator.admin? && !impersonator.blocked?
2016-06-02 11:05:42 +05:30
end
end