mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
DEV: add site setting to disable watched word checking in user fields (#25411)
adding a hidden sitesetting, `disable_watched_word_checking_in_user_fields` - false by default. if set to true, you can use any word at all in user profile fields. meta: https://meta.discourse.org/t/watched-words-scope/282699/20
This commit is contained in:
@@ -151,7 +151,10 @@ class User < ActiveRecord::Base
|
||||
validates :name, user_full_name: true, if: :will_save_change_to_name?, length: { maximum: 255 }
|
||||
validates :ip_address, allowed_ip_address: { on: :create }
|
||||
validates :primary_email, presence: true, unless: :skip_email_validation
|
||||
validates :validatable_user_fields_values, watched_words: true, unless: :custom_fields_clean?
|
||||
validates :validatable_user_fields_values,
|
||||
watched_words: true,
|
||||
unless: :should_skip_user_fields_validation?
|
||||
|
||||
validates_associated :primary_email,
|
||||
message: ->(_, user_email) { user_email[:value]&.errors&.[](:email)&.first }
|
||||
|
||||
@@ -180,7 +183,7 @@ class User < ActiveRecord::Base
|
||||
before_save :ensure_password_is_hashed
|
||||
before_save :match_primary_group_changes
|
||||
before_save :check_if_title_is_badged_granted
|
||||
before_save :apply_watched_words, unless: :custom_fields_clean?
|
||||
before_save :apply_watched_words, unless: :should_skip_user_fields_validation?
|
||||
|
||||
after_save :expire_tokens_if_password_changed
|
||||
after_save :clear_global_notice_if_needed
|
||||
@@ -354,6 +357,10 @@ class User < ActiveRecord::Base
|
||||
)
|
||||
end
|
||||
|
||||
def should_skip_user_fields_validation?
|
||||
custom_fields_clean? || SiteSetting.disable_watched_word_checking_in_user_fields
|
||||
end
|
||||
|
||||
def secured_sidebar_category_ids(user_guardian = nil)
|
||||
user_guardian ||= guardian
|
||||
|
||||
|
||||
Reference in New Issue
Block a user