Class: Decidim::Admin::PromoteManagedUser
- Inherits:
-
Command
- Object
- Command
- Decidim::Admin::PromoteManagedUser
- Defined in:
- app/commands/decidim/admin/promote_managed_user.rb
Overview
A command with all the business logic to promote a managed user.
Managed users can be promoted to standard users. It means they will be invited to the application and will lose the managed flag so the user cannot be impersonated anymore.
Instance Attribute Summary collapse
-
#form ⇒ Object
readonly
Returns the value of attribute form.
-
#user ⇒ Object
readonly
Returns the value of attribute user.
Instance Method Summary collapse
-
#call ⇒ Object
Executes the command.
-
#initialize(form, user) ⇒ PromoteManagedUser
constructor
Public: Initializes the command.
Constructor Details
#initialize(form, user) ⇒ PromoteManagedUser
Public: Initializes the command.
form - A form object with the params. user - The user to promote
16 17 18 19 |
# File 'app/commands/decidim/admin/promote_managed_user.rb', line 16 def initialize(form, user) @form = form @user = user end |
Instance Attribute Details
#form ⇒ Object (readonly)
Returns the value of attribute form.
37 38 39 |
# File 'app/commands/decidim/admin/promote_managed_user.rb', line 37 def form @form end |
#user ⇒ Object (readonly)
Returns the value of attribute user.
37 38 39 |
# File 'app/commands/decidim/admin/promote_managed_user.rb', line 37 def user @user end |
Instance Method Details
#call ⇒ Object
Executes the command. Broadcasts these events:
-
:ok when everything is valid.
-
:invalid if the form was not valid and we could not proceed.
Returns nothing.
27 28 29 30 31 32 33 34 35 |
# File 'app/commands/decidim/admin/promote_managed_user.rb', line 27 def call return broadcast(:invalid) if form.invalid? || !user.managed? || email_already_exists? promote_user invite_user create_action_log broadcast(:ok) end |