Skip to content

Commit

Permalink
Merge pull request #2287 from 18F/stages/rc-2018-07-05
Browse files Browse the repository at this point in the history
Fix Voice OTP bug in RC 61
  • Loading branch information
monfresh authored Jul 3, 2018
2 parents bf829bb + e14a2c9 commit 0cafde6
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
1 change: 1 addition & 0 deletions .reek
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,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.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

0 comments on commit 0cafde6

Please sign in to comment.