diff options
| author | Markus Koller <markus-koller@gmx.ch> | 2017-01-24 21:42:15 +0100 |
|---|---|---|
| committer | Alexis Reigel <mail@koffeinfrei.org> | 2017-04-06 10:01:13 +0200 |
| commit | 57374feabe1428b2ea06a6a3cac244612128095d (patch) | |
| tree | ee06e37ef946dddcaba840a2446dc2e11bdf0406 | |
| parent | aaa49c2c4e9473726814e3ce183c2e3e4072d64b (diff) | |
| download | gitlab-ce-57374feabe1428b2ea06a6a3cac244612128095d.tar.gz | |
Move AuthHelper#two_factor_skippable? into ApplicationController
| -rw-r--r-- | app/controllers/application_controller.rb | 7 | ||||
| -rw-r--r-- | app/helpers/auth_helper.rb | 12 |
2 files changed, 7 insertions, 12 deletions
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 6a6e335d314..b197fd2157e 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -25,6 +25,7 @@ class ApplicationController < ActionController::Base helper_method :can?, :current_application_settings helper_method :import_sources_enabled?, :github_import_enabled?, :gitea_import_enabled?, :github_import_configured?, :gitlab_import_enabled?, :gitlab_import_configured?, :bitbucket_import_enabled?, :bitbucket_import_configured?, :google_code_import_enabled?, :fogbugz_import_enabled?, :git_import_enabled?, :gitlab_project_import_enabled? + helper_method :two_factor_grace_period_expired?, :two_factor_skippable? rescue_from Encoding::CompatibilityError do |exception| log_exception(exception) @@ -278,6 +279,12 @@ class ApplicationController < ActionController::Base date && (date + two_factor_grace_period.hours) < Time.current end + def two_factor_skippable? + two_factor_authentication_required? && + !current_user.two_factor_enabled? && + !two_factor_grace_period_expired? + end + def skip_two_factor? session[:skip_tfa] && session[:skip_tfa] > Time.current end diff --git a/app/helpers/auth_helper.rb b/app/helpers/auth_helper.rb index 101fe579da2..9c71d6c7f4c 100644 --- a/app/helpers/auth_helper.rb +++ b/app/helpers/auth_helper.rb @@ -64,18 +64,6 @@ 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 - def unlink_allowed?(provider) %w(saml cas3).exclude?(provider.to_s) end |
