Sha256: f82f1fc8ace04c74e885b7f7c21ea1d9855e4f408b1968b4574fb114cbff541b
Contents?: true
Size: 1.28 KB
Versions: 2
Compression:
Stored size: 1.28 KB
Contents
module MnoEnterprise class ImpersonateController < ApplicationController include MnoEnterprise::ImpersonateHelper before_filter :authenticate_user!, except: [:destroy] before_filter :current_user_must_be_admin!, except: [:destroy] # Perform the user impersonate action # GET /impersonate/user/123 def create session[:impersonator_redirect_path] = params[:redirect_path].presence @user = MnoEnterprise::User.find(params[:user_id]) if @user.present? impersonate(@user) else flash[:notice] = "User doesn't exist" end path = mnoe_home_path path = add_param_to_fragment(path, 'dhbRefId', params[:dhbRefId]) if params[:dhbRefId].present? redirect_to path end # Revert the user impersonation # GET /impersonation/revert def destroy if current_impersonator # user = current_user revert_impersonate end redirect_to session.delete(:impersonator_redirect_path).presence || '/admin/' end private def current_user_must_be_admin! unless current_user.admin_role.present? flash[:error] = "You don't have access to this section." redirect_to :back end rescue ActionController::RedirectBackError redirect_to '/' end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
mno-enterprise-api-3.3.1 | app/controllers/mno_enterprise/impersonate_controller.rb |
mno-enterprise-api-3.3.0 | app/controllers/mno_enterprise/impersonate_controller.rb |