FEATURE: passwords must have a minimum number of unique characters, configurable with a new setting

This commit is contained in:
Neil Lalonde
2017-02-09 15:00:22 -05:00
parent d68dd5b967
commit 1bcb835446
5 changed files with 41 additions and 6 deletions

View File

@ -18,6 +18,8 @@ class PasswordValidator < ActiveModel::EachValidator
record.errors.add(attribute, :same_as_current)
elsif SiteSetting.block_common_passwords && CommonPasswords.common_password?(value)
record.errors.add(attribute, :common)
elsif value.chars.uniq.size < SiteSetting.password_unique_characters
record.errors.add(attribute, :unique_characters)
end
end