Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Duplicate Warden strategy :two_factor_authenticatable #228

Open
evgenyneu opened this issue Oct 5, 2022 · 1 comment
Open

Duplicate Warden strategy :two_factor_authenticatable #228

evgenyneu opened this issue Oct 5, 2022 · 1 comment

Comments

@evgenyneu
Copy link

evgenyneu commented Oct 5, 2022

Hi,

When I run the generator

./bin/rails generate devise_two_factor user

It adds the following code to config/initializers/devise.rb file:

config.warden do |manager|
    manager.default_strategies(:scope => :user).unshift :two_factor_authenticatable
end

However, everything works fine if I comment it out. Moreover, if I print out the array returned by manager.default_strategies(:scope => :user) it shows two duplicate items [:two_factor_authenticatable, :two_factor_authenticatable]. I'm using this code to print it out:

config.warden do |manager|
    manager.default_strategies(:scope => :user).unshift :two_factor_authenticatable
    pp 'manager.default_strategies', manager.default_strategies(:scope => :user)
end

It looks like the generator for the config/initializers/devise.rb can be removed since the :two_factor_authenticatable Warden strategy for the User is already added when we do

class User < ApplicationRecord
  devise :two_factor_authenticatable

?

I'm using devise-two-factor (5.0.0), devise (4.8.1) and rails (7.0.3.1).

@abhishek-unthinkable
Copy link

+1 found the same on version 2.2.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants