diff --git a/app/controllers/users/webauthn_setup_controller.rb b/app/controllers/users/webauthn_setup_controller.rb index 9c2510f76b5..eb4503648dd 100644 --- a/app/controllers/users/webauthn_setup_controller.rb +++ b/app/controllers/users/webauthn_setup_controller.rb @@ -27,6 +27,7 @@ def new user_opted_remember_device_cookie: user_opted_remember_device_cookie, remember_device_default: remember_device_default, platform_authenticator: @platform_authenticator, + url_options:, ) properties = result.to_h.merge(analytics_properties) analytics.webauthn_setup_visit(**properties) @@ -54,6 +55,7 @@ def confirm user_opted_remember_device_cookie: user_opted_remember_device_cookie, remember_device_default: remember_device_default, platform_authenticator: @platform_authenticator, + url_options:, ) properties = result.to_h.merge(analytics_properties) analytics.multi_factor_auth_setup(**properties) diff --git a/app/presenters/webauthn_setup_presenter.rb b/app/presenters/webauthn_setup_presenter.rb index d931f55cab9..c7b44ca9bb8 100644 --- a/app/presenters/webauthn_setup_presenter.rb +++ b/app/presenters/webauthn_setup_presenter.rb @@ -1,13 +1,17 @@ class WebauthnSetupPresenter < SetupPresenter + include Rails.application.routes.url_helpers include ActionView::Helpers::UrlHelper include ActionView::Helpers::TranslationHelper + attr_reader :url_options + def initialize( current_user:, user_fully_authenticated:, user_opted_remember_device_cookie:, remember_device_default:, - platform_authenticator: + platform_authenticator:, + url_options: ) super( current_user: current_user, @@ -17,6 +21,7 @@ def initialize( ) @platform_authenticator = platform_authenticator + @url_options = url_options end def image_path @@ -54,23 +59,21 @@ def intro_html t( 'forms.webauthn_platform_setup.intro_html', app_name: APP_NAME, - link: intro_link, + link: link_to( + t('forms.webauthn_platform_setup.intro_link_text'), + help_center_redirect_path( + category: 'trouble-signing-in', + article: 'face-or-touch-unlock', + flow: :two_factor_authentication, + step: :webauthn_setup, + ), + ), ) else t('forms.webauthn_setup.intro_html') end end - def intro_link - link_to( - t('forms.webauthn_platform_setup.intro_link_text'), - MarketingSite.help_center_article_url( - category: 'get-started', - article: 'authentication-options', - ), - ) - end - def nickname_label if @platform_authenticator t('forms.webauthn_platform_setup.nickname') diff --git a/spec/presenters/webauthn_setup_presenter_spec.rb b/spec/presenters/webauthn_setup_presenter_spec.rb index 8902c9c2c19..6f386cb6066 100644 --- a/spec/presenters/webauthn_setup_presenter_spec.rb +++ b/spec/presenters/webauthn_setup_presenter_spec.rb @@ -1,17 +1,14 @@ require 'rails_helper' RSpec.describe WebauthnSetupPresenter do + include Rails.application.routes.url_helpers + include ActionView::Helpers::UrlHelper + let(:user) { build(:user) } let(:user_fully_authenticated) { false } let(:user_opted_remember_device_cookie) { true } let(:remember_device_default) { true } let(:platform_authenticator) { false } - let(:intro_link) do - MarketingSite.help_center_article_url( - category: 'get-started', - article: 'authentication-options', - ) - end let(:presenter) do described_class.new( current_user: user, @@ -19,6 +16,7 @@ user_opted_remember_device_cookie: user_opted_remember_device_cookie, remember_device_default: remember_device_default, platform_authenticator: platform_authenticator, + url_options: {}, ) end @@ -46,13 +44,6 @@ it { is_expected.to eq(t('forms.webauthn_setup.intro_html')) } end - describe '#intro_link' do - subject { presenter.intro_link } - - it { is_expected.to include(t('forms.webauthn_platform_setup.intro_link_text')) } - it { is_expected.to include(intro_link) } - end - describe '#nickname_label' do subject { presenter.nickname_label } @@ -92,6 +83,28 @@ it { is_expected.to eq(t('headings.webauthn_platform_setup.new')) } end + describe '#intro_html' do + subject { presenter.intro_html } + + it do + is_expected.to eq( + t( + 'forms.webauthn_platform_setup.intro_html', + app_name: APP_NAME, + link: link_to( + t('forms.webauthn_platform_setup.intro_link_text'), + help_center_redirect_path( + category: 'trouble-signing-in', + article: 'face-or-touch-unlock', + flow: :two_factor_authentication, + step: :webauthn_setup, + ), + ), + ), + ) + end + end + describe '#nickname_label' do subject { presenter.nickname_label } diff --git a/spec/views/users/webauthn_setup/new.html.erb_spec.rb b/spec/views/users/webauthn_setup/new.html.erb_spec.rb index e9c7a180102..934e07d41a8 100644 --- a/spec/views/users/webauthn_setup/new.html.erb_spec.rb +++ b/spec/views/users/webauthn_setup/new.html.erb_spec.rb @@ -15,6 +15,7 @@ user_opted_remember_device_cookie: true, remember_device_default: true, platform_authenticator: platform_authenticator, + url_options: {}, ) end