summaryrefslogtreecommitdiff
path: root/app/controllers/profiles
diff options
context:
space:
mode:
authorAlexis Reigel <mail@koffeinfrei.org>2017-03-08 12:09:15 +0100
committerAlexis Reigel <mail@koffeinfrei.org>2017-04-06 10:01:13 +0200
commitb7ca7330ec9119c6a5eea00df20ddc690d4dafe1 (patch)
treef82f20893753d8ed3341201ee9e42b7a55c5f4c9 /app/controllers/profiles
parenta49c5d18364fc3f4b475d639e5de55fd1558351c (diff)
downloadgitlab-ce-b7ca7330ec9119c6a5eea00df20ddc690d4dafe1.tar.gz
state the reason to the user for the required 2fa
Diffstat (limited to 'app/controllers/profiles')
-rw-r--r--app/controllers/profiles/two_factor_auths_controller.rb21
1 files changed, 17 insertions, 4 deletions
diff --git a/app/controllers/profiles/two_factor_auths_controller.rb b/app/controllers/profiles/two_factor_auths_controller.rb
index b52134d89a4..d3fa81cd623 100644
--- a/app/controllers/profiles/two_factor_auths_controller.rb
+++ b/app/controllers/profiles/two_factor_auths_controller.rb
@@ -13,11 +13,24 @@ class Profiles::TwoFactorAuthsController < Profiles::ApplicationController
current_user.save! if current_user.changed?
if two_factor_authentication_required? && !current_user.two_factor_enabled?
- if two_factor_grace_period_expired?
- flash.now[:alert] = 'You must enable Two-Factor Authentication for your account.'
- else
+ two_factor_authentication_reason(
+ global: lambda do
+ flash.now[:alert] =
+ 'The global settings require you to enable Two-Factor Authentication for your account.'
+ end,
+ group: lambda do |groups|
+ group_links = groups.map { |group| view_context.link_to group.full_name, group_path(group) }.to_sentence
+
+ flash.now[:alert] = %{
+ The group settings for #{group_links} require you to enable
+ Two-Factor Authentication for your account.
+ }.html_safe
+ end
+ )
+
+ unless two_factor_grace_period_expired?
grace_period_deadline = current_user.otp_grace_period_started_at + two_factor_grace_period.hours
- flash.now[:alert] = "You must enable Two-Factor Authentication for your account before #{l(grace_period_deadline)}."
+ flash.now[:alert] << " You need to do this before #{l(grace_period_deadline)}."
end
end