Class: Decidim::Verifications::IdDocuments::Admin::ConfirmUserOfflineAuthorization

Inherits:
Command
  • Object
show all
Defined in:
app/commands/decidim/verifications/id_documents/admin/confirm_user_offline_authorization.rb

Overview

A command to confirm a previous partial offline authorization.

Instance Method Summary collapse

Constructor Details

#initialize(form) ⇒ ConfirmUserOfflineAuthorization

Public: Initializes the command.

form - A form object with the verification data to confirm it.



12
13
14
# File 'app/commands/decidim/verifications/id_documents/admin/confirm_user_offline_authorization.rb', line 12

def initialize(form)
  @form = form
end

Instance Method Details

#callObject

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.



22
23
24
25
26
27
28
29
30
31
32
# File 'app/commands/decidim/verifications/id_documents/admin/confirm_user_offline_authorization.rb', line 22

def call
  return broadcast(:invalid) unless form.valid?
  return broadcast(:invalid) unless authorization

  if confirmation_successful?
    grant_authorization
    broadcast(:ok)
  else
    broadcast(:invalid)
  end
end