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
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ def create
result = TotpVerificationForm.new(current_user, params.require(:code).strip).submit

analytics.track_mfa_submit_event(result.to_h)
irs_attempts_api_tracker.multi_factor_auth_verify_totp(success: result.success?)

if result.success?
handle_valid_otp
Expand Down
9 changes: 9 additions & 0 deletions app/services/irs_attempts_api/tracker_events.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,15 @@ def multi_factor_auth_enroll_totp(success:)
)
end

# Tracks when the user has attempted to verify via the TOTP MFA method to access their account
# @param [Boolean] success
def multi_factor_auth_verify_totp(success:)
track_event(
:totp_verify,
success: success,
)
end

# Tracks when user confirms registration email
# @param [Boolean] success
# @param [String] email
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
describe TwoFactorAuthentication::TotpVerificationController do
before do
stub_analytics
stub_attempts_tracker
end

describe '#create' do
Expand Down Expand Up @@ -46,6 +47,8 @@
with(attributes)
expect(@analytics).to receive(:track_event).
with('User marked authenticated', authentication_type: :valid_2fa)
expect(@irs_attempts_api_tracker).to receive(:track_event).
with(:totp_verify, success: true)

post :create, params: { code: generate_totp_code(@secret) }
end
Expand Down Expand Up @@ -92,6 +95,8 @@
with(attributes)
expect(@analytics).to receive(:track_event).
with('Multi-Factor Authentication: max attempts reached')
expect(@irs_attempts_api_tracker).to receive(:track_event).
with(:totp_verify, success: false)
expect(PushNotification::HttpPush).to receive(:deliver).
with(PushNotification::MfaLimitAccountLockedEvent.new(user: subject.current_user))

Expand Down