diff options
author | Gabriel Mazetto <gabriel@gitlab.com> | 2015-12-24 05:02:52 +0300 |
---|---|---|
committer | Gabriel Mazetto <gabriel@gitlab.com> | 2015-12-25 00:01:30 +0300 |
commit | 31fb2b7702345fbf597c2cb17466567776433a56 (patch) | |
tree | c00ab27dc891b6ed2ce6b061c58f2fa6913edf15 /app/helpers/auth_helper.rb | |
parent | 33964469b38e2b36b200b20fe3061371a5f5ab18 (diff) |
Grace period support for TFA
Diffstat (limited to 'app/helpers/auth_helper.rb')
-rw-r--r-- | app/helpers/auth_helper.rb | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/app/helpers/auth_helper.rb b/app/helpers/auth_helper.rb index 2c81ea1623c..0cfc0565e84 100644 --- a/app/helpers/auth_helper.rb +++ b/app/helpers/auth_helper.rb @@ -50,5 +50,17 @@ module AuthHelper current_user.identities.exists?(provider: provider.to_s) end + def two_factor_skippable? + current_application_settings.require_two_factor_authentication && + !current_user.two_factor_enabled && + current_application_settings.two_factor_grace_period && + !two_factor_grace_period_expired? + end + + def two_factor_grace_period_expired? + current_user.otp_grace_period_started_at && + (current_user.otp_grace_period_started_at + current_application_settings.two_factor_grace_period.hours) < Time.current + end + extend self end |