2
0
Fork 0
mirror of https://github.com/discourse/discourse.git synced 2025-09-06 10:50:21 +08:00

FIX: password validator was being too strict

This commit is contained in:
Sam 2017-02-14 09:17:52 -05:00
parent dba16b57cb
commit 8feb94e13f
3 changed files with 6 additions and 5 deletions

View file

@ -18,7 +18,7 @@ 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.inject(Hash.new(0)) { |h,char| h[char] += 1; h }.reject { |k,v| v > 1 }.size < SiteSetting.password_unique_characters
elsif value.split("").uniq.length < SiteSetting.password_unique_characters
record.errors.add(attribute, :unique_characters)
end
end