Class: Decidim::AccessRequests::Verification::Admin::ConfirmUserAccessRequest

Inherits:
Rectify::Command
  • Object
show all
Defined in:
app/commands/decidim/access_requests/verification/admin/confirm_user_access_request.rb

Overview

A command to confirm a previous partial authorization. This is just a wrapper class to call the ConfirmUserAuthorization command because we add the email notifications here.

Instance Method Summary collapse

Constructor Details

#initialize(authorization, form) ⇒ ConfirmUserAccessRequest

Public: Initializes the command.

authorization - An Authorization to be confirmed. form - A form object with the verification data to confirm it.



15
16
17
18
# File 'app/commands/decidim/access_requests/verification/admin/confirm_user_access_request.rb', line 15

def initialize(authorization, form)
  @authorization = authorization
  @form = form
end

Instance Method Details

#callObject

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.



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'app/commands/decidim/access_requests/verification/admin/confirm_user_access_request.rb', line 26

def call
  parent = self

  Decidim::Verifications::ConfirmUserAuthorization.call(authorization, form) do
    on(:ok) do
      send_notification
      parent.send(:broadcast, :ok)
    end

    on(:invalid) do
      parent.send(:broadcast, :invalid)
    end

    on(:already_confirmed) do
      parent.send(:broadcast, :invalid)
    end
  end
end