Class: Decidim::Admin::CloseSessionManagedUser

Inherits:
Command
  • Object
show all
Defined in:
app/commands/decidim/admin/close_session_managed_user.rb

Overview

A command with all the business logic to close a current impersonation session.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(user, current_user) ⇒ CloseSessionManagedUser

Public: Initializes the command.

user - The user impersonated. current_user - The current user doing the impersonation.



11
12
13
14
# File 'app/commands/decidim/admin/close_session_managed_user.rb', line 11

def initialize(user, current_user)
  @user = user
  @current_user = current_user
end

Instance Attribute Details

#current_userObject (readonly)

Returns the value of attribute current_user.



30
31
32
# File 'app/commands/decidim/admin/close_session_managed_user.rb', line 30

def current_user
  @current_user
end

#userObject (readonly)

Returns the value of attribute user.



30
31
32
# File 'app/commands/decidim/admin/close_session_managed_user.rb', line 30

def user
  @user
end

Instance Method Details

#callObject

Executes the command. Broadcasts these events:

  • :ok when everything is valid.

  • :invalid if the impersonation is not valid.

Returns nothing.



22
23
24
25
26
27
28
# File 'app/commands/decidim/admin/close_session_managed_user.rb', line 22

def call
  return broadcast(:invalid) if impersonation_log.blank?

  close_session

  broadcast(:ok)
end