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
4 changes: 4 additions & 0 deletions app/controllers/account_reset/request_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,17 @@ def show
def create
create_account_reset_request
flash[:email] = current_user.email_addresses.take.email

redirect_to account_reset_confirm_request_url
end

private

def create_account_reset_request
response = AccountReset::CreateRequest.new(current_user).call
irs_attempts_api_tracker.account_reset_request_submitted(
success: response.success?,
)
analytics.account_reset_request(**response.to_h, **analytics_attributes)
end

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
@@ -1,5 +1,14 @@
module IrsAttemptsApi
module TrackerEvents
# @param [Boolean] success True if the email and password matched
# account Reset Deletion Requested
def account_reset_request_submitted(success:)
track_event(
:account_reset_request_submitted,
success: success,
)
end

# @param [String] email The submitted email address
# @param [Boolean] success True if the email and password matched
# A user has submitted an email address and password for authentication
Expand Down
11 changes: 11 additions & 0 deletions spec/controllers/account_reset/request_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,17 @@
post :create
end

it 'logs the visit to attempts api' do
user = create(:user, :with_piv_or_cac, :with_backup_code)
stub_sign_in_before_2fa(user)
stub_attempts_tracker

expect(@irs_attempts_api_tracker).to receive(:track_event).
with(:account_reset_request_submitted, success: true)

get :create
end

it 'redirects to root if user not signed in' do
post :create

Expand Down