Class: Decidim::Verifications::PerformAuthorizationStep

Inherits:
Rectify::Command
  • Object
show all
Defined in:
decidim-verifications/app/commands/decidim/verifications/perform_authorization_step.rb

Overview

A command to create a partial authorization for a user.

Instance Method Summary collapse

Constructor Details

#initialize(authorization, handler) ⇒ PerformAuthorizationStep

Public: Initializes the command.

authorization - An Authorization object. handler - An AuthorizationHandler object.


11
12
13
14
# File 'decidim-verifications/app/commands/decidim/verifications/perform_authorization_step.rb', line 11

def initialize(authorization, handler)
  @authorization = authorization
  @handler = handler
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.


22
23
24
25
26
27
28
# File 'decidim-verifications/app/commands/decidim/verifications/perform_authorization_step.rb', line 22

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

  update_verification_data

  broadcast(:ok)
end