summaryrefslogtreecommitdiff
path: root/app/controllers/concerns/enforces_two_factor_authentication.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/controllers/concerns/enforces_two_factor_authentication.rb')
-rw-r--r--app/controllers/concerns/enforces_two_factor_authentication.rb18
1 files changed, 9 insertions, 9 deletions
diff --git a/app/controllers/concerns/enforces_two_factor_authentication.rb b/app/controllers/concerns/enforces_two_factor_authentication.rb
index b1b6e21644e..c8de041d5bd 100644
--- a/app/controllers/concerns/enforces_two_factor_authentication.rb
+++ b/app/controllers/concerns/enforces_two_factor_authentication.rb
@@ -10,19 +10,12 @@
module EnforcesTwoFactorAuthentication
extend ActiveSupport::Concern
- MFA_HELP_PAGE = Rails.application.routes.url_helpers.help_page_url(
- 'user/profile/account/two_factor_authentication.html',
- anchor: 'enable-two-factor-authentication'
- )
-
included do
before_action :check_two_factor_requirement, except: [:route_not_found]
# to include this in controllers inheriting from `ActionController::Metal`
# we need to add this block
- if respond_to?(:helper_method)
- helper_method :two_factor_grace_period_expired?, :two_factor_skippable?
- end
+ helper_method :two_factor_grace_period_expired?, :two_factor_skippable? if respond_to?(:helper_method)
end
def check_two_factor_requirement
@@ -33,7 +26,7 @@ module EnforcesTwoFactorAuthentication
when GraphqlController
render_error(
_("Authentication error: enable 2FA in your profile settings to continue using GitLab: %{mfa_help_page}") %
- { mfa_help_page: MFA_HELP_PAGE },
+ { mfa_help_page: mfa_help_page_url },
status: :unauthorized
)
else
@@ -84,6 +77,13 @@ module EnforcesTwoFactorAuthentication
def two_factor_verifier
@two_factor_verifier ||= Gitlab::Auth::TwoFactorAuthVerifier.new(current_user) # rubocop:disable Gitlab/ModuleWithInstanceVariables
end
+
+ def mfa_help_page_url
+ Rails.application.routes.url_helpers.help_page_url(
+ 'user/profile/account/two_factor_authentication.html',
+ anchor: 'enable-two-factor-authentication'
+ )
+ end
end
EnforcesTwoFactorAuthentication.prepend_mod_with('EnforcesTwoFactorAuthentication')