From 61ca1a0af6c093e3816b0ee7e2fcb57702e22366 Mon Sep 17 00:00:00 2001 From: Sebastien Savater Date: Sun, 21 May 2023 16:14:07 +0200 Subject: [PATCH] :two_factor_authenticatable should be inserted on top --- lib/devise-two-factor.rb | 2 +- spec/devise/models/two_factor_authenticatable_spec.rb | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/devise-two-factor.rb b/lib/devise-two-factor.rb index a4b1870..4e7d32e 100644 --- a/lib/devise-two-factor.rb +++ b/lib/devise-two-factor.rb @@ -31,7 +31,7 @@ module Devise end Devise.add_module(:two_factor_authenticatable, :route => :session, :strategy => true, - :controller => :sessions, :model => true) + :controller => :sessions, :model => true, :insert_at => 0) Devise.add_module(:two_factor_backupable, :route => :session, :strategy => true, :controller => :sessions, :model => true) diff --git a/spec/devise/models/two_factor_authenticatable_spec.rb b/spec/devise/models/two_factor_authenticatable_spec.rb index fcb03ab..d0fcee1 100644 --- a/spec/devise/models/two_factor_authenticatable_spec.rb +++ b/spec/devise/models/two_factor_authenticatable_spec.rb @@ -25,6 +25,10 @@ def save(validate) end describe ::Devise::Models::TwoFactorAuthenticatable do + it 'should be inserted prior to other devise modules' do + expect(Devise::ALL.first).to eq(:two_factor_authenticatable) + end + context 'When included in a class' do subject { TwoFactorAuthenticatableDouble.new }