Module: Devise::Models::UncommonPassword
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/devise/uncommon_password/model.rb
Overview
The UncommonPassword module adds a new validation for Devise Models. No modifications to routes or controllers needed. Simply add :uncommon_password to the list of included modules in your devise module, and all new registrations will be blocked if they use a common password.
Defined Under Namespace
Modules: ClassMethods
Class Method Summary collapse
-
.common_passwords ⇒ Object
Returns a list of the 100 most common passwords.
Class Method Details
.common_passwords ⇒ Object
Returns a list of the 100 most common passwords.
11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/devise/uncommon_password/model.rb', line 11 def self.common_passwords passwords_file = File.join(File.dirname(__FILE__), "passwords.txt") passwords = [] File.open(passwords_file, "r") do |file| file.each { |password| passwords << password.chomp.downcase } end passwords.select! {|password| Devise.password_length.include? password.length } #passwords[0..99] passwords[0..Devise.password_matches-1] end |