mirror of
https://github.com/discourse/discourse.git
synced 2025-05-22 22:43:33 +08:00
FEATURE: enforce admin password validation when signing up via developer email
This commit is contained in:
@ -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
|
||||
|
Reference in New Issue
Block a user