Class: Decidim::Verifications::RevokeAllAuthorizationsJob

Inherits:
ApplicationJob
  • Object
show all
Defined in:
app/jobs/decidim/verifications/revoke_all_authorizations_job.rb

Instance Method Summary collapse

Instance Method Details

#perform(organization, current_user) ⇒ Object

Revokes every granted authorization for the given organization.

Parameters:

  • organization (Decidim::Organization)

    The organization whose authorizations will be revoked

  • current_user (Decidim::User)

    the current user.



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'app/jobs/decidim/verifications/revoke_all_authorizations_job.rb', line 12

def perform(organization, current_user)
  auths = Decidim::Verifications::Authorizations.new(
    organization:,
    granted: true
  ).query.includes(transfers: :records)

  auths.find_each do |auth|
    Decidim.traceability.perform_action!(
      :destroy,
      auth,
      current_user
    ) do
      auth.destroy
    end
  end
end