Commit e60887bb authored by Kenneth Chu's avatar Kenneth Chu Committed by Matthias Käppler

Add link to troubleshooting steps in error message

parent b11b5142
...@@ -66,7 +66,7 @@ class Profiles::TwoFactorAuthsController < Profiles::ApplicationController ...@@ -66,7 +66,7 @@ class Profiles::TwoFactorAuthsController < Profiles::ApplicationController
render 'create' render 'create'
else else
@error = _('Invalid pin code') @error = { message: _('Invalid pin code.') }
@qr_code = build_qr_code @qr_code = build_qr_code
if Feature.enabled?(:webauthn) if Feature.enabled?(:webauthn)
......
...@@ -43,7 +43,9 @@ ...@@ -43,7 +43,9 @@
.gl-alert.gl-alert-danger.gl-mb-5 .gl-alert.gl-alert-danger.gl-mb-5
.gl-alert-container .gl-alert-container
.gl-alert-content .gl-alert-content
= @error %p.gl-alert-body.gl-md-0
= @error[:message]
= link_to _('Try the troubleshooting steps here.'), help_page_path('user/profile/account/two_factor_authentication.md', anchor: 'troubleshooting'), target: '_blank', rel: 'noopener noreferrer'
.form-group .form-group
= label_tag :pin_code, _('Pin code'), class: "label-bold" = label_tag :pin_code, _('Pin code'), class: "label-bold"
= text_field_tag :pin_code, nil, class: "form-control gl-form-input", required: true, data: { qa_selector: 'pin_code_field' } = text_field_tag :pin_code, nil, class: "form-control gl-form-input", required: true, data: { qa_selector: 'pin_code_field' }
......
...@@ -18859,7 +18859,7 @@ msgstr "" ...@@ -18859,7 +18859,7 @@ msgstr ""
msgid "Invalid period" msgid "Invalid period"
msgstr "" msgstr ""
msgid "Invalid pin code" msgid "Invalid pin code."
msgstr "" msgstr ""
msgid "Invalid pod_name" msgid "Invalid pod_name"
...@@ -36651,6 +36651,9 @@ msgstr "" ...@@ -36651,6 +36651,9 @@ msgstr ""
msgid "Try out GitLab Pipelines" msgid "Try out GitLab Pipelines"
msgstr "" msgstr ""
msgid "Try the troubleshooting steps here."
msgstr ""
msgid "Try to fork again" msgid "Try to fork again"
msgstr "" msgstr ""
......
...@@ -175,7 +175,7 @@ RSpec.describe Profiles::TwoFactorAuthsController do ...@@ -175,7 +175,7 @@ RSpec.describe Profiles::TwoFactorAuthsController do
it 'assigns error' do it 'assigns error' do
go go
expect(assigns[:error]).to eq _('Invalid pin code') expect(assigns[:error]).to eq({ message: 'Invalid pin code.' })
end end
it 'assigns qr_code' do it 'assigns qr_code' do
......
...@@ -45,6 +45,19 @@ RSpec.describe 'Two factor auths' do ...@@ -45,6 +45,19 @@ RSpec.describe 'Two factor auths' do
expect(page).to have_content('Status: Enabled') expect(page).to have_content('Status: Enabled')
end end
end end
context 'when invalid pin is provided' do
let_it_be(:user) { create(:omniauth_user) }
it 'renders a error alert with a link to the troubleshooting section' do
visit profile_two_factor_auth_path
fill_in 'pin_code', with: '123'
click_button 'Register with two-factor app'
expect(page).to have_link('Try the troubleshooting steps here.', href: help_page_path('user/profile/account/two_factor_authentication.md', anchor: 'troubleshooting'))
end
end
end end
context 'when user has two-factor authentication enabled' do context 'when user has two-factor authentication enabled' do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment