Sha256: f85f6cb2a0418afa21368595ddb6958f12a358ebcbda0e8b965679da0d9dbe9b
Contents?: true
Size: 1.15 KB
Versions: 34
Compression:
Stored size: 1.15 KB
Contents
# frozen_string_literal: true module Decidim module Verifications # A command to revoke authorizations class RevokeAllAuthorizations < Rectify::Command # Public: Initializes the command. # # organization - Organization object. # current_user - The current user. def initialize(organization, current_user) @organization = organization @current_user = current_user end # Executes the command. Broadcasts these events: # # - :ok when everything is valid. # - :invalid if the handler wasn't valid and we couldn't proceed. # # Returns nothing. def call return broadcast(:invalid) unless @organization auths = Decidim::Verifications::Authorizations.new( organization: organization, granted: true ).query auths.find_each do |auth| Decidim.traceability.perform_action!( :destroy, auth, current_user ) do auth.destroy end end broadcast(:ok) end private attr_reader :organization, :current_user end end end
Version data entries
34 entries across 34 versions & 1 rubygems