Class: Decidim::Initiatives::ValidateMobilePhone
- Inherits:
-
Command
- Object
- Command
- Decidim::Initiatives::ValidateMobilePhone
- Defined in:
- app/commands/decidim/initiatives/validate_mobile_phone.rb
Overview
Command to check if mobile phone has an authorization and deliver sms code
Instance Method Summary collapse
-
#call ⇒ Object
Executes the command.
-
#initialize(form, user) ⇒ ValidateMobilePhone
constructor
Public: Initializes the command.
Constructor Details
#initialize(form, user) ⇒ ValidateMobilePhone
Public: Initializes the command.
form - A MobilePhoneForm. user - The user which mobile phone must be validated.
12 13 14 15 |
# File 'app/commands/decidim/initiatives/validate_mobile_phone.rb', line 12 def initialize(form, user) @form = form @user = user end |
Instance Method Details
#call ⇒ Object
Executes the command. Broadcasts these events:
-
:ok when everything is valid. Returns the verification metadata of
the form.
-
:invalid if the user does not have an authorization for sms in ok
status or the phone number associated with its authorization does not match the form number.
24 25 26 27 28 29 30 |
# File 'app/commands/decidim/initiatives/validate_mobile_phone.rb', line 24 def call return broadcast(:invalid) unless && phone_match? generate_code broadcast(:ok, @verification_metadata) end |