FEATURE: enforce admin password validation when signing up via developer email

This commit is contained in:
Arpit Jalan
2016-03-03 23:31:31 +05:30
parent 04990e7c5c
commit 36f82aa68c
4 changed files with 44 additions and 35 deletions

View File

@ -6,7 +6,7 @@ class PasswordValidator < ActiveModel::EachValidator
return unless record.password_required?
if value.nil?
record.errors.add(attribute, :blank)
elsif value.length < SiteSetting.min_admin_password_length && record.admin?
elsif value.length < SiteSetting.min_admin_password_length && (record.admin? || is_developer?(record.email))
record.errors.add(attribute, :too_short, count: SiteSetting.min_admin_password_length)
elsif value.length < SiteSetting.min_password_length
record.errors.add(attribute, :too_short, count: SiteSetting.min_password_length)
@ -19,4 +19,8 @@ class PasswordValidator < ActiveModel::EachValidator
end
end
def is_developer?(value)
Rails.configuration.respond_to?(:developer_emails) && Rails.configuration.developer_emails.include?(value)
end
end