mirror of
https://github.com/discourse/discourse.git
synced 2025-09-06 10:50:21 +08:00
FEATURE: enforce admin password validation when signing up via developer email
This commit is contained in:
parent
04990e7c5c
commit
36f82aa68c
4 changed files with 44 additions and 35 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue