mirror of
https://github.com/discourse/discourse.git
synced 2025-09-06 10:50:21 +08:00
fix unique char counting in password validator
This commit is contained in:
parent
137e941814
commit
94e1105af7
3 changed files with 8 additions and 8 deletions
|
@ -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.uniq.size < SiteSetting.password_unique_characters
|
||||
elsif value.chars.inject(Hash.new(0)) { |h,char| h[char] += 1; h }.reject { |k,v| v > 1 }.size < SiteSetting.password_unique_characters
|
||||
record.errors.add(attribute, :unique_characters)
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue