Spiegel von
https://github.com/paviliondev/discourse-custom-wizard.git
synchronisiert 2024-11-22 17:30:29 +01:00
Fix wizard locales for non-staff
Dieser Commit ist enthalten in:
Ursprung
a52b54c463
Commit
9006126e04
2 geänderte Dateien mit 17 neuen und 1 gelöschten Zeilen
16
plugin.rb
16
plugin.rb
|
@ -191,5 +191,21 @@ after_initialize do
|
|||
end
|
||||
end
|
||||
|
||||
## TODO: We shouldn't be overriding the entire method here. Make this more lightweight.
|
||||
add_to_class(:extra_locales_controller, :show) do
|
||||
bundle = params[:bundle]
|
||||
|
||||
unless URI(request.referer).path.include? '/w/'
|
||||
raise Discourse::InvalidAccess.new if bundle !~ /^(admin|wizard)$/ || !current_user&.staff?
|
||||
end
|
||||
|
||||
if params[:v]&.size == 32
|
||||
hash = ExtraLocalesController.bundle_js_hash(bundle)
|
||||
immutable_for(24.hours) if hash == params[:v]
|
||||
end
|
||||
|
||||
render plain: ExtraLocalesController.bundle_js(bundle), content_type: "application/javascript"
|
||||
end
|
||||
|
||||
DiscourseEvent.trigger(:custom_wizard_ready)
|
||||
end
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
<%= preload_script "wizard-plugin" %>
|
||||
<%= preload_script "pretty-text-bundle" %>
|
||||
<%= preload_script "locales/#{I18n.locale}" %>
|
||||
<script src="<%= Discourse.base_uri %>/extra-locales/wizard"></script>
|
||||
<script src="<%= ExtraLocalesController.url("wizard") %>"></script>
|
||||
<%= csrf_meta_tags %>
|
||||
|
||||
<%- unless customization_disabled? %>
|
||||
|
|
Laden …
In neuem Issue referenzieren