0
0
Fork 1
Spiegel von https://github.com/paviliondev/discourse-custom-wizard.git synchronisiert 2024-11-13 21:42:53 +01:00

FIX: reduce scope of ExtraLocalesController override

Dieser Commit ist enthalten in:
Angus McLeod 2019-11-11 09:48:26 +11:00
Ursprung ef81a07918
Commit 642e3cca98

Datei anzeigen

@ -191,20 +191,25 @@ after_initialize do
end end
end end
## TODO: We shouldn't be overriding the entire method here. Make this more lightweight. module CustomWizardExtraLocalesController
add_to_class(:extra_locales_controller, :show) do def show
bundle = params[:bundle] if request.referer && URI(request.referer).path.include?('/w/')
bundle = params[:bundle]
unless URI(request.referer).path.include? '/w/' if params[:v]&.size == 32
raise Discourse::InvalidAccess.new if bundle !~ /^(admin|wizard)$/ || !current_user&.staff? hash = ExtraLocalesController.bundle_js_hash(bundle)
immutable_for(1.year) if hash == params[:v]
end
render plain: ExtraLocalesController.bundle_js(bundle), content_type: "application/javascript"
else
super
end
end end
end
if params[:v]&.size == 32 class ::ExtraLocalesController
hash = ExtraLocalesController.bundle_js_hash(bundle) prepend CustomWizardExtraLocalesController
immutable_for(24.hours) if hash == params[:v]
end
render plain: ExtraLocalesController.bundle_js(bundle), content_type: "application/javascript"
end end
DiscourseEvent.trigger(:custom_wizard_ready) DiscourseEvent.trigger(:custom_wizard_ready)