mirror of
https://github.com/discourse/discourse.git
synced 2025-06-02 04:08:41 +08:00
FIX: Mark secure media upload insecure automatically if used for theme component (#8413)
When uploading a file to a theme component, and that file is existing and has already been marked as secure, we now automatically mark the file as secure: false, change the ACL, and log the action as the user (also rebake the posts for the upload)
This commit is contained in:
@ -23,12 +23,24 @@ class Admin::ThemesController < Admin::AdminController
|
||||
if upload.errors.count > 0
|
||||
render_json_error upload
|
||||
else
|
||||
# we assume a user intends to make some media public
|
||||
# if they are uploading it to a theme component
|
||||
mark_upload_insecure(upload) if upload.secure?
|
||||
render json: { upload_id: upload.id }, status: :created
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def mark_upload_insecure(upload)
|
||||
upload.update_secure_status(secure_override_value: false)
|
||||
StaffActionLogger.new(current_user).log_change_upload_secure_status(
|
||||
upload_id: upload.id,
|
||||
new_value: false
|
||||
)
|
||||
Jobs.enqueue(:rebake_posts_for_upload, id: upload.id)
|
||||
end
|
||||
|
||||
def generate_key_pair
|
||||
require 'sshkey'
|
||||
k = SSHKey.generate
|
||||
|
Reference in New Issue
Block a user