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

Remove duplicate regist stratery #135

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -174,13 +174,13 @@ Rails.application.config.filter_parameters += [:otp_attempt]
## Backup Codes
Devise-Two-Factor is designed with extensibility in mind. One such extension, `TwoFactorBackupable`, is included and serves as a good example of how to extend this gem. This plugin allows you to add the ability to generate single-use backup codes for a user, which they may use to bypass two-factor authentication, in the event that they lose access to their device.

To install it, you need to add the `:two_factor_backupable` directive to your model.
To install it, you either add the `:two_factor_backupable` directive to your model

```ruby
devise :two_factor_backupable
```

You'll also be required to enable the `:two_factor_backupable` strategy, by adding the following line to your Warden config in your Devise initializer, substituting :user for the name of your Devise scope.
or by adding the following line to your Warden config in your Devise initializer, substituting :user for the name of your Devise scope.

```ruby
manager.default_strategies(:scope => :user).unshift :two_factor_backupable
Expand Down
11 changes: 0 additions & 11 deletions lib/generators/devise_two_factor/devise_two_factor_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ class DeviseTwoFactorGenerator < Rails::Generators::NamedBase

def install_devise_two_factor
create_devise_two_factor_migration
inject_strategies_into_warden_config
inject_devise_directives_into_model
end

Expand All @@ -29,16 +28,6 @@ def create_devise_two_factor_migration
Rails::Generators.invoke('active_record:migration', migration_arguments)
end

def inject_strategies_into_warden_config
config_path = File.join('config', 'initializers', 'devise.rb')

content = " config.warden do |manager|\n" \
" manager.default_strategies(:scope => :#{singular_table_name}).unshift :two_factor_authenticatable\n" \
" end\n\n"

inject_into_file(config_path, content, after: "Devise.setup do |config|\n")
end

def inject_devise_directives_into_model
model_path = File.join('app', 'models', "#{file_path}.rb")

Expand Down