Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .reek
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ UncommunicativeModuleName:
UnusedParameters:
exclude:
- SmsOtpSenderJob#perform
- VoiceOtpSenderJob#perform
UnusedPrivateMethod:
exclude:
- ApplicationController
Expand Down
8 changes: 7 additions & 1 deletion app/jobs/voice_otp_sender_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,15 @@ class VoiceOtpSenderJob < ApplicationJob

queue_as :voice

def perform(code:, phone:, otp_created_at:)
# rubocop:disable Lint/UnusedMethodArgument
# locale is an argument used for the Twilio/Authy Verify service, which uses
# a localized message for delivering OTPs via SMS and Voice. As of this
# writing, we are only using Verify for non-US SMS, but we might expand
# to Voice later.
def perform(code:, phone:, otp_created_at:, locale: nil)
send_otp(TwilioService::Utils.new, code, phone) if otp_valid?(otp_created_at)
end
# rubocop:enable Lint/UnusedMethodArgument

private

Expand Down
11 changes: 11 additions & 0 deletions spec/features/two_factor_authentication/sign_in_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,17 @@
expect(current_path).to eq login_two_factor_path(otp_delivery_preference: 'sms')
end
end

context 'with voice option and US number' do
it 'sends the code via VoiceOtpSenderJob and redirects to prompt for the code' do
sign_in_before_2fa
select_2fa_option('voice')
fill_in 'user_phone_form_phone', with: '7035551212'
click_send_security_code

expect(current_path).to eq login_two_factor_path(otp_delivery_preference: 'voice')
end
end
end

def phone_field
Expand Down