Skip to content

Commit

Permalink
LG-10965: Show backup code reminder for partner-initiated requests
Browse files Browse the repository at this point in the history
changelog: User-Facing Improvements, Backup Codes, Show backup code reminder for partner-initiated requests
  • Loading branch information
aduth committed Jan 15, 2025
1 parent 2e85e66 commit 99242b7
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 8 deletions.
2 changes: 1 addition & 1 deletion app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -238,13 +238,13 @@ def after_sign_in_path_for(_user)
:recommend_for_authentication,
)
return second_mfa_reminder_url if user_needs_second_mfa_reminder?
return backup_code_reminder_url if user_needs_backup_code_reminder?
return sp_session_request_url_with_updated_params if sp_session.key?(:request_url)
signed_in_url
end

def signed_in_url
return idv_verify_by_mail_enter_code_url if current_user.gpo_verification_pending_profile?
return backup_code_reminder_url if user_needs_backup_code_reminder?
account_path
end

Expand Down
10 changes: 8 additions & 2 deletions app/views/users/backup_code_reminder/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,16 @@

<div class="margin-top-5 margin-bottom-2">
<%= render ButtonComponent.new(
url: account_path,
url: backup_code_reminder_path,
method: :post,
params: { has_codes: true },
big: true,
wide: true,
).with_content(t('forms.backup_code_reminder.have_codes')) %>
</div>

<%= link_to t('forms.backup_code_reminder.need_new_codes'), backup_code_regenerate_path %>
<%= render ButtonComponent.new(
url: backup_code_reminder_path,
method: :post,
unstyled: true,
).with_content(t('forms.backup_code_reminder.need_new_codes')) %>
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
require 'rails_helper'

RSpec.feature 'sign in with backup code' do
include SamlAuthHelper
include InteractionHelper

let(:user) { create(:user) }
Expand Down Expand Up @@ -77,5 +78,37 @@

expect(page).to have_current_path(backup_code_regenerate_path)
end

context 'when signing in to partner application' do
before do
visit_idp_from_sp_with_ial1(:oidc)
end

it 'redirects the user to backup code reminder url and allows user to confirm possession' do
fill_in t('forms.two_factor.backup_code'), with: codes.sample
click_submit_default

expect(page).to have_current_path(backup_code_reminder_path)

click_on t('forms.backup_code_reminder.have_codes')

expect(page).to have_current_path(sign_up_completed_path)
end

it 'redirects the user to the backup code reminder url and allows user to create new codes' do
fill_in t('forms.two_factor.backup_code'), with: codes.sample
click_submit_default

expect(page).to have_current_path(backup_code_reminder_path)
click_on t('forms.backup_code_reminder.need_new_codes')

expect(page).to have_current_path(backup_code_regenerate_path)
click_on t('account.index.backup_code_confirm_regenerate')

click_continue

expect(page).to have_current_path(sign_up_completed_path)
end
end
end
end
7 changes: 2 additions & 5 deletions spec/views/users/backup_code_reminder/show.html.erb_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,12 @@
it 'has a cancel link to account path' do
render

expect(rendered).to have_link(t('forms.backup_code_reminder.have_codes'))
expect(rendered).to have_button(t('forms.backup_code_reminder.have_codes'))
end

it 'has a regenerate backup code link' do
render

expect(rendered).to have_link(
t('forms.backup_code_reminder.need_new_codes'),
href: backup_code_regenerate_path,
)
expect(rendered).to have_button(t('forms.backup_code_reminder.need_new_codes'))
end
end

0 comments on commit 99242b7

Please sign in to comment.