Class: MnoEnterprise::ImpersonateController

Inherits:
ApplicationController
  • Object
show all
Includes:
ImpersonateHelper
Defined in:
app/controllers/mno_enterprise/impersonate_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject

Perform the user impersonate action GET /impersonate/user/123



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'app/controllers/mno_enterprise/impersonate_controller.rb', line 10

def create
  session[:impersonator_redirect_path] = params[:redirect_path].presence
  @user = MnoEnterprise::User.find(params[:user_id])
  if @user.present?
    if @user.admin_role.present?
      flash[:notice] = 'User is a staff member'
    else
      impersonate(@user)
    end
  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

#destroyObject

Revert the user impersonation GET /impersonation/revert



31
32
33
34
35
36
37
# File 'app/controllers/mno_enterprise/impersonate_controller.rb', line 31

def destroy
  if current_impersonator
    # user = current_user
    revert_impersonate
  end
  redirect_to session.delete(:impersonator_redirect_path).presence || '/admin/'
end