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

FEATURE: don't allow username and password to be the same

This commit is contained in:
Neil Lalonde 2015-02-25 11:59:57 -05:00
parent bcb0346595
commit cf81b3f86d
6 changed files with 42 additions and 0 deletions

View file

@ -8,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 record.username.present? && value == record.username
record.errors.add(attribute, :same_as_username)
elsif SiteSetting.block_common_passwords && CommonPasswords.common_password?(value)
record.errors.add(attribute, :common)
end