提交 8e665140 编写于 作者: M Markus Koller 提交者: Alexis Reigel

Rename check_2fa_requirement to check_two_factor_requirement

上级 7140e09e
......@@ -2,18 +2,18 @@
#
# Controller concern to enforce two-factor authentication requirements
#
# Upon inclusion, adds `check_2fa_requirement` as a before_action, and
# makes `two_factor_grace_period_expired?` and `two_factor_skippable?`
# Upon inclusion, adds `check_two_factor_requirement` as a before_action,
# and makes `two_factor_grace_period_expired?` and `two_factor_skippable?`
# available as view helpers.
module EnforcesTwoFactorAuthentication
extend ActiveSupport::Concern
included do
before_action :check_2fa_requirement
before_action :check_two_factor_requirement
helper_method :two_factor_grace_period_expired?, :two_factor_skippable?
end
def check_2fa_requirement
def check_two_factor_requirement
if two_factor_authentication_required? && current_user && !current_user.two_factor_enabled? && !skip_two_factor?
redirect_to profile_two_factor_auth_path
end
......
class Profiles::TwoFactorAuthsController < Profiles::ApplicationController
skip_before_action :check_2fa_requirement
skip_before_action :check_two_factor_requirement
def show
unless current_user.otp_secret
......
......@@ -3,7 +3,7 @@ class SessionsController < Devise::SessionsController
include Devise::Controllers::Rememberable
include Recaptcha::ClientHelper
skip_before_action :check_2fa_requirement, only: [:destroy]
skip_before_action :check_two_factor_requirement, only: [:destroy]
prepend_before_action :check_initial_setup, only: [:new]
prepend_before_action :authenticate_with_two_factor,
......
......@@ -117,8 +117,8 @@ describe ApplicationController do
context 'two-factor authentication' do
let(:controller) { ApplicationController.new }
describe '#check_2fa_requirement' do
subject { controller.send :check_2fa_requirement }
describe '#check_two_factor_requirement' do
subject { controller.send :check_two_factor_requirement }
it 'does not redirect if 2FA is not required' do
allow(controller).to receive(:two_factor_authentication_required?).and_return(false)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册