Skip to content
Snippets Groups Projects
Commit 57374fea authored by Markus Koller's avatar Markus Koller Committed by Alexis Reigel
Browse files

Move AuthHelper#two_factor_skippable? into ApplicationController

parent aaa49c2c
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -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)
Loading
Loading
@@ -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
Loading
Loading
Loading
Loading
@@ -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
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment