Rename check_2fa_requirement to check_two_factor_requirement
This commit is contained in:
parent
7140e09e39
commit
8e66514056
|
@ -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
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
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)
|
||||
|
|
Loading…
Reference in New Issue