Class: Decidim::Admin::ImpersonateManagedUser
- Inherits:
-
Rectify::Command
- Object
- Rectify::Command
- Decidim::Admin::ImpersonateManagedUser
- Defined in:
- app/commands/decidim/admin/impersonate_managed_user.rb
Overview
A command with all the business logic to impersonate a managed user.
Instance Method Summary collapse
-
#call ⇒ Object
Executes the command.
-
#initialize(form, user) ⇒ ImpersonateManagedUser
constructor
Public: Initializes the command.
Constructor Details
#initialize(form, user) ⇒ ImpersonateManagedUser
Public: Initializes the command.
form - The form with the authorization info user - The user to impersonate
11 12 13 14 |
# File 'app/commands/decidim/admin/impersonate_managed_user.rb', line 11 def initialize(form, user) @form = form @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 29 |
# File 'app/commands/decidim/admin/impersonate_managed_user.rb', line 22 def call return broadcast(:invalid) unless user.managed? && create_impersonation_log enqueue_expire_job broadcast(:ok) end |