Class: Decidim::Initiatives::ValidateSmsCode

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

Overview

Command to check if sms code provided by user is valid

Instance Method Summary collapse

Constructor Details

#initialize(form, verification_metadata) ⇒ ValidateSmsCode

Public: Initializes the command.

form - form containing confirmation_code. verification_metadata - metadata containing the required code.


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

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

Instance Method Details

#callObject

Executes the command. Broadcasts these events:

  • :ok when everithing is valid.

  • :invalid if verification_metadata is not present or the form code is

    invalid.
    

Returns nothing.


23
24
25
26
27
# File 'decidim-initiatives/app/commands/decidim/initiatives/validate_sms_code.rb', line 23

def call
  return broadcast(:invalid) unless  && valid_code?

  broadcast(:ok)
end