mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
Block passwords that are in the top 5000 most common passwords. Site setting block_common_passwords can disable this feature.
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
require_dependency "common_passwords/common_passwords"
|
||||
|
||||
class PasswordValidator < ActiveModel::EachValidator
|
||||
|
||||
def validate_each(record, attribute, value)
|
||||
@@ -6,6 +8,8 @@ class PasswordValidator < ActiveModel::EachValidator
|
||||
record.errors.add(attribute, :blank)
|
||||
elsif value.length < SiteSetting.min_password_length
|
||||
record.errors.add(attribute, :too_short, count: SiteSetting.min_password_length)
|
||||
elsif SiteSetting.block_common_passwords && CommonPasswords.common_password?(value)
|
||||
record.errors.add(attribute, :common)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user