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
12 changes: 11 additions & 1 deletion app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ def two_2fa_setup
end

def after_multiple_2fa_sign_up
if session[:sp]
if user_needs_sign_up_completed_page?
sign_up_completed_url
elsif current_user.decorate.password_reset_profile.present?
reactivate_account_url
Expand Down Expand Up @@ -240,6 +240,16 @@ def render_full_width(template, **opts)
render template, **opts, layout: 'base'
end

def user_needs_sign_up_completed_page?
issuer = sp_session[:issuer]
return false unless issuer
!user_has_ial1_identity_for_issuer?(issuer)
end

def user_has_ial1_identity_for_issuer?(issuer)
current_user.identities.where(service_provider: issuer, ial: 1).any?
end

def analytics_exception_info(exception)
{
backtrace: Rails.backtrace_cleaner.send(:filter, exception.backtrace),
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/sign_up/completions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def show
end

def update
track_completion_event('agency-page')
track_completion_event('agency-page') if user_needs_sign_up_completed_page?
handle_verified_attributes
if decider.go_back_to_mobile_app?
sign_user_out_and_instruct_to_go_back_to_mobile_app
Expand Down Expand Up @@ -59,7 +59,7 @@ def loa3?
end

def return_to_account
track_completion_event('account-page')
track_completion_event('account-page') if user_needs_sign_up_completed_page?
redirect_to account_url
end

Expand Down
2 changes: 1 addition & 1 deletion app/controllers/sign_up/personal_keys_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def assign_initial_personal_key
end

def next_step
if session[:sp]
if user_needs_sign_up_completed_page?
sign_up_completed_url
elsif current_user.decorate.password_reset_profile.present?
reactivate_account_url
Expand Down
2 changes: 2 additions & 0 deletions spec/controllers/sign_up/completions_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@
stub_sign_in
subject.session[:sp] = {
loa3: false,
issuer: 'foo',
request_url: 'http://example.com',
}

Expand Down Expand Up @@ -137,6 +138,7 @@
user = create(:user, profiles: [create(:profile, :verified, :active)])
stub_sign_in(user)
subject.session[:sp] = {
issuer: 'foo',
loa3: true,
request_url: 'http://example.com',
}
Expand Down
6 changes: 4 additions & 2 deletions spec/controllers/sign_up/personal_keys_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@
describe '#update' do
context 'sp present' do
it 'redirects to the sign up completed url' do
subject.session[:sp] = 'true'
sp = ServiceProvider.from_issuer('http://localhost:3000')
subject.session[:sp] = { issuer: sp.issuer, request_id: '123' }
stub_sign_in

patch :update
Expand All @@ -52,7 +53,8 @@
end

it 'tracks CSRF errors' do
subject.session[:sp] = 'true'
sp = ServiceProvider.from_issuer('http://localhost:3000')
subject.session[:sp] = { issuer: sp.issuer, request_id: '123' }
stub_sign_in
stub_analytics
analytics_hash = {
Expand Down