Class: Decidim::Verifications::RevokeByConditionAuthorizations
- Inherits:
-
Command
- Object
- Command
- Decidim::Verifications::RevokeByConditionAuthorizations
- Defined in:
- app/commands/decidim/verifications/revoke_by_condition_authorizations.rb
Overview
A command to revoke authorizations with filter
Instance Method Summary collapse
-
#call ⇒ Object
Executes the command.
-
#initialize(organization, form) ⇒ RevokeByConditionAuthorizations
constructor
Public: Initializes the command.
Constructor Details
#initialize(organization, form) ⇒ RevokeByConditionAuthorizations
Public: Initializes the command.
organization - Organization object. current_user - The current user. form - A form object with the verification data to confirm it.
13 14 15 16 |
# File 'app/commands/decidim/verifications/revoke_by_condition_authorizations.rb', line 13 def initialize(organization, form) @organization = organization @form = form end |
Instance Method Details
#call ⇒ Object
Executes the command. Broadcasts these events:
-
:ok when everything is valid.
-
:invalid if the handler was not valid and we could not proceed.
Returns nothing.
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'app/commands/decidim/verifications/revoke_by_condition_authorizations.rb', line 24 def call return broadcast(:invalid) unless @organization return broadcast(:invalid) unless @form.valid? # Check before date if @form.before_date.present? = if @form.impersonated_only? Decidim::Verifications::AuthorizationsBeforeDate.new( organization:, date: @form.before_date, granted: true, impersonated_only: @form.impersonated_only ) else Decidim::Verifications::AuthorizationsBeforeDate.new( organization:, date: @form.before_date, granted: true ) end auths = .query auths.find_each do |auth| Decidim.traceability.perform_action!( :destroy, auth, current_user ) do auth.destroy end end broadcast(:ok) else broadcast(:invalid) end end |