gitlab-org--gitlab-foss/app/controllers/admin/application_controller.rb
James Newton 3bb626f91c refactor login as to be impersonation with better login/logout
Modifies the existing "login as" feature to be called impersonation, as
well as keeping track of who is impersonating to revert back to that
user without having to log out.
2015-10-29 11:00:17 +01:00

17 lines
478 B
Ruby

# Provides a base class for Admin controllers to subclass
#
# Automatically sets the layout and ensures an administrator is logged in
class Admin::ApplicationController < ApplicationController
before_action :authenticate_admin!
layout 'admin'
def authenticate_admin!
return render_404 unless current_user.is_admin?
end
def authorize_impersonator!
if session[:impersonator_id]
User.find_by!(username: session[:impersonator_id]).admin?
end
end
end