Commit 57374fea authored by Markus Koller's avatar Markus Koller Committed by Alexis Reigel
Browse files

Move AuthHelper#two_factor_skippable? into ApplicationController

parent a7ba31312e00
......@@ -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 @@ def two_factor_grace_period_expired?
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
......
......@@ -64,18 +64,6 @@ def auth_active?(provider)
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
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment