Commit 8e665140 authored by Markus Koller's avatar Markus Koller Committed by Alexis Reigel

Rename check_2fa_requirement to check_two_factor_requirement

parent 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%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment