Skip to content

Commit

Permalink
Make gem add bcrypt more resilient
Browse files Browse the repository at this point in the history
  • Loading branch information
lazaronixon committed Oct 26, 2024
1 parent bfc80b5 commit d0b3227
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
## New version

* We don't need to add `config.action_mailer.default_url_options` anymore
* Make gem add bcrypt more resilient

## Authentication Zero 4.0.2 ##

Expand Down
10 changes: 9 additions & 1 deletion lib/generators/authentication/authentication_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@ class AuthenticationGenerator < Rails::Generators::Base
source_root File.expand_path("templates", __dir__)

def add_gems
gem "bcrypt", "~> 3.1.7", comment: "Use Active Model has_secure_password [https://guides.rubyonrails.org/active_model_basics.html#securepassword]"
if bcrypt_present?
uncomment_lines "Gemfile", /gem "bcrypt"/
else
gem "bcrypt", "~> 3.1.7", comment: "Use Active Model has_secure_password [https://guides.rubyonrails.org/active_model_basics.html#securepassword]"
end

if options.pwned?
gem "pwned", comment: "Use Pwned to check if a password has been found in any of the huge data breaches [https://github.com/philnash/pwned]"
Expand Down Expand Up @@ -241,6 +245,10 @@ def sudoable?
options.sudoable? && !options.api?
end

def bcrypt_present?
File.read("Gemfile").include?('gem "bcrypt"')
end

def importmaps?
Rails.root.join("config/importmap.rb").exist?
end
Expand Down

0 comments on commit d0b3227

Please sign in to comment.