0
0
Fork 1
Spiegel von https://github.com/paviliondev/discourse-custom-wizard.git synchronisiert 2024-11-23 01:40:29 +01:00

Fix wizard locales for non-staff

Dieser Commit ist enthalten in:
Angus McLeod 2019-08-27 14:49:29 +10:00
Ursprung a52b54c463
Commit 9006126e04
2 geänderte Dateien mit 17 neuen und 1 gelöschten Zeilen

Datei anzeigen

@ -191,5 +191,21 @@ after_initialize do
end end
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) DiscourseEvent.trigger(:custom_wizard_ready)
end end

Datei anzeigen

@ -17,7 +17,7 @@
<%= preload_script "wizard-plugin" %> <%= preload_script "wizard-plugin" %>
<%= preload_script "pretty-text-bundle" %> <%= preload_script "pretty-text-bundle" %>
<%= preload_script "locales/#{I18n.locale}" %> <%= preload_script "locales/#{I18n.locale}" %>
<script src="<%= Discourse.base_uri %>/extra-locales/wizard"></script> <script src="<%= ExtraLocalesController.url("wizard") %>"></script>
<%= csrf_meta_tags %> <%= csrf_meta_tags %>
<%- unless customization_disabled? %> <%- unless customization_disabled? %>