Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LG-10965: Show backup code reminder for partner-initiated requests #11744

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
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