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
2 changes: 2 additions & 0 deletions app/controllers/users/webauthn_setup_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
27 changes: 15 additions & 12 deletions app/presenters/webauthn_setup_presenter.rb
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -17,6 +21,7 @@ def initialize(
)

@platform_authenticator = platform_authenticator
@url_options = url_options
end

def image_path
Expand Down Expand Up @@ -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')
Expand Down
39 changes: 26 additions & 13 deletions spec/presenters/webauthn_setup_presenter_spec.rb
Original file line number Diff line number Diff line change
@@ -1,24 +1,22 @@
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,
user_fully_authenticated: user_fully_authenticated,
user_opted_remember_device_cookie: user_opted_remember_device_cookie,
remember_device_default: remember_device_default,
platform_authenticator: platform_authenticator,
url_options: {},
)
end

Expand Down Expand Up @@ -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 }

Expand Down Expand Up @@ -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 }

Expand Down
1 change: 1 addition & 0 deletions spec/views/users/webauthn_setup/new.html.erb_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
user_opted_remember_device_cookie: true,
remember_device_default: true,
platform_authenticator: platform_authenticator,
url_options: {},
)
end

Expand Down