Class: Decidim::Verifications::ConfirmUserAuthorization
- Inherits:
-
Command
- Object
- Command
- Decidim::Verifications::ConfirmUserAuthorization
- Defined in:
- app/commands/decidim/verifications/confirm_user_authorization.rb
Overview
A command to confirm a previous partial authorization.
Direct Known Subclasses
Decidim::Verifications::CsvCensus::ConfirmCensusAuthorization
Constant Summary collapse
- MAX_FAILED_ATTEMPTS =
Number of failed confirmation attempts before throttling.
2
Instance Method Summary collapse
-
#call ⇒ Object
Executes the command.
-
#initialize(authorization, form, session) ⇒ ConfirmUserAuthorization
constructor
Public: Initializes the command.
Constructor Details
#initialize(authorization, form, session) ⇒ ConfirmUserAuthorization
Public: Initializes the command.
authorization - An Authorization to be confirmed. form - A form object with the verification data to confirm it.
14 15 16 17 18 |
# File 'app/commands/decidim/verifications/confirm_user_authorization.rb', line 14 def initialize(, form, session) @authorization = @form = form @session = session end |
Instance Method Details
#call ⇒ Object
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.
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'app/commands/decidim/verifications/confirm_user_authorization.rb', line 26 def call return already_confirmed! if .granted? return invalid! unless form.valid? throttle! if too_many_failed_attempts? if confirmation_successful? valid! else invalid! end rescue StandardError => e invalid!(e.) end |