Class: Decidim::Admin::CloseSessionManagedUser
- Inherits:
-
Command
- Object
- Command
- Decidim::Admin::CloseSessionManagedUser
- 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
-
#current_user ⇒ Object
readonly
Returns the value of attribute current_user.
-
#user ⇒ Object
readonly
Returns the value of attribute user.
Instance Method Summary collapse
-
#call ⇒ Object
Executes the command.
-
#initialize(user, current_user) ⇒ CloseSessionManagedUser
constructor
Public: Initializes the command.
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_user ⇒ Object (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 |
#user ⇒ Object (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
#call ⇒ Object
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 |