FIX: public sidebar sections belong to system user (#20972)

Before, public sidebar sections were belonging to admin. However, a better choice is system user.
This commit is contained in:
Krzysztof Kotlarek
2023-04-05 10:52:18 +10:00
committed by GitHub
parent 6b9dd22ba7
commit b72282123b
7 changed files with 88 additions and 13 deletions

View File

@@ -12,6 +12,8 @@ class SidebarSection < ActiveRecord::Base
accepts_nested_attributes_for :sidebar_urls, allow_destroy: true
before_save :set_system_user_for_public_section
validates :title,
presence: true,
uniqueness: {
@@ -20,6 +22,12 @@ class SidebarSection < ActiveRecord::Base
length: {
maximum: MAX_TITLE_LENGTH,
}
private
def set_system_user_for_public_section
self.user_id = Discourse.system_user.id if self.public
end
end
# == Schema Information