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 }