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: 12 additions & 0 deletions app/controllers/users/webauthn_setup_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ class WebauthnSetupController < ApplicationController
before_action :apply_secure_headers_override
before_action :set_webauthn_setup_presenter
before_action :confirm_recently_authenticated_2fa
before_action :validate_existing_platform_authenticator

helper_method :in_multi_mfa_selection_flow?

Expand Down Expand Up @@ -108,6 +109,17 @@ def show_delete

private

def validate_existing_platform_authenticator
if platform_authenticator? && in_account_creation_flow? &&
current_user.webauthn_configurations.platform_authenticators.present?
redirect_to authentication_methods_setup_path
end
end

def platform_authenticator?
params[:platform] == 'true'
end

def set_webauthn_setup_presenter
@presenter = SetupPresenter.new(
current_user: current_user,
Expand Down
12 changes: 12 additions & 0 deletions spec/controllers/users/webauthn_setup_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,18 @@
expect(additional_mfa_check).to be_truthy
end
end

context 'when the back button is clicked after platform is added' do
let(:user) { create(:user, :with_webauthn_platform) }
before do
controller.user_session[:in_account_creation_flow] = true
end
it 'should redirect to authentication methods setup' do
get :new, params: { platform: true }

expect(response).to redirect_to(authentication_methods_setup_path)
end
end
end

describe 'multiple MFA handling' do
Expand Down