summaryrefslogtreecommitdiff
path: root/app/controllers/application_controller.rb
diff options
context:
space:
mode:
authorGabriel Mazetto <gabriel@gitlab.com>2015-12-24 02:04:41 -0200
committerGabriel Mazetto <gabriel@gitlab.com>2015-12-24 19:01:30 -0200
commitb61a5bc20cbfcd8a2c914f19e8786a989bf69198 (patch)
tree782acf1b8e437a2f6f88935ceeddf88b5d03c447 /app/controllers/application_controller.rb
parent31fb2b7702345fbf597c2cb17466567776433a56 (diff)
downloadgitlab-ce-b61a5bc20cbfcd8a2c914f19e8786a989bf69198.tar.gz
specs for forced two-factor authentication and grace period
simplified code and fixed stuffs
Diffstat (limited to 'app/controllers/application_controller.rb')
-rw-r--r--app/controllers/application_controller.rb10
1 files changed, 3 insertions, 7 deletions
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
index 978a269ca52..a945b38e35f 100644
--- a/app/controllers/application_controller.rb
+++ b/app/controllers/application_controller.rb
@@ -226,12 +226,7 @@ class ApplicationController < ActionController::Base
def check_tfa_requirement
if two_factor_authentication_required? && current_user && !current_user.two_factor_enabled && !skip_two_factor?
- grace_period_started = current_user.otp_grace_period_started_at
- grace_period_deadline = grace_period_started + two_factor_grace_period.hours
-
- deadline_text = "until #{l(grace_period_deadline)}" unless two_factor_grace_period_expired?(grace_period_started)
- redirect_to new_profile_two_factor_auth_path,
- alert: "You must configure Two-Factor Authentication in your account #{deadline_text}"
+ redirect_to new_profile_two_factor_auth_path
end
end
@@ -377,7 +372,8 @@ class ApplicationController < ActionController::Base
current_application_settings.two_factor_grace_period
end
- def two_factor_grace_period_expired?(date)
+ def two_factor_grace_period_expired?
+ date = current_user.otp_grace_period_started_at
date && (date + two_factor_grace_period.hours) < Time.current
end