Commit 168df138 authored by Drew Blessing's avatar Drew Blessing Committed by Drew Blessing

Skip two factor setup for help pages

Bypass the required two factor setup, When two factor authentication
is required to be configured for a user. These help pages can already
be accessed when a user is not signed in. They should also be
accessible when two factor is required so users can access
documentation, if needed.
parent 7e63db80
......@@ -2,6 +2,7 @@
class HelpController < ApplicationController
skip_before_action :authenticate_user!, unless: :public_visibility_restricted?
skip_before_action :check_two_factor_requirement
feature_category :not_owned
layout 'help'
......
---
title: Skip two factor setup for help pages
merge_request: 54739
author:
type: fixed
......@@ -132,6 +132,18 @@ RSpec.describe HelpController do
expect(response).to redirect_to(new_user_session_path)
end
end
context 'when two factor is required' do
before do
stub_two_factor_required
end
it 'does not redirect to two factor auth' do
get :index
expect(response).not_to redirect_to(profile_two_factor_auth_path)
end
end
end
describe 'GET #show' do
......@@ -152,6 +164,16 @@ RSpec.describe HelpController do
end
it_behaves_like 'documentation pages local render'
context 'when two factor is required' do
before do
stub_two_factor_required
end
it 'does not redirect to two factor auth' do
expect(response).not_to redirect_to(profile_two_factor_auth_path)
end
end
end
context 'when a custom help_page_documentation_url is set in database' do
......@@ -254,4 +276,9 @@ RSpec.describe HelpController do
def stub_readme(content)
expect_file_read(Rails.root.join('doc', 'README.md'), content: content)
end
def stub_two_factor_required
allow(controller).to receive(:two_factor_authentication_required?).and_return(true)
allow(controller).to receive(:current_user_requires_two_factor?).and_return(true)
end
end
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