diff --git a/app/assets/javascripts/authentication-complete.js.no-module.es6 b/app/assets/javascripts/authentication-complete.js.no-module.es6 new file mode 100644 index 0000000000..ad768b6426 --- /dev/null +++ b/app/assets/javascripts/authentication-complete.js.no-module.es6 @@ -0,0 +1,17 @@ +(function() { + const authenticationData = JSON.parse( + document.getElementById("data-authentication").dataset.authenticationData + ); + + Discourse.showingSignup = true; + require("discourse/routes/application").default.reopen({ + actions: { + didTransition: function() { + Em.run.next(function() { + Discourse.authenticationComplete(authenticationData); + }); + return this._super(); + } + } + }); +})(); diff --git a/app/assets/javascripts/preload-application-data.js.no-module.es6 b/app/assets/javascripts/preload-application-data.js.no-module.es6 index a544c1a9a1..7291d91950 100644 --- a/app/assets/javascripts/preload-application-data.js.no-module.es6 +++ b/app/assets/javascripts/preload-application-data.js.no-module.es6 @@ -39,4 +39,26 @@ Discourse.S3CDN = setupData.s3Cdn; Discourse.S3BaseUrl = setupData.s3BaseUrl; } + + Ember.RSVP.configure("onerror", function(e) { + // Ignore TransitionAborted exceptions that bubble up + if (e && e.message === "TransitionAborted") { + return; + } + + if (Discourse.Environment === "development") { + if (e) { + if (e.message || e.stack) { + console.log(e.message); + console.log(e.stack); + } else { + console.log("Uncaught promise: ", e); + } + } else { + console.log("A promise failed but was not caught."); + } + } + + window.onerror(e && e.message, null, null, null, e); + }); })(); diff --git a/app/views/common/_discourse_javascript.html.erb b/app/views/common/_discourse_javascript.html.erb deleted file mode 100644 index 98f63940d1..0000000000 --- a/app/views/common/_discourse_javascript.html.erb +++ /dev/null @@ -1,38 +0,0 @@ - - - - -<%= preload_script 'browser-update' %> diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 140c1b9ac9..5fbcc74137 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -55,6 +55,11 @@ <%= build_plugin_html 'server:before-head-close' %> <%= tag.meta id: 'data-discourse-setup', data: client_side_setup_data %> + + <%- if !current_user && flash[:authentication_data] %> + + <%= preload_script "authentication-complete" %> + <%- end %> @@ -106,7 +111,7 @@ <%= yield :data %> - <%= render :partial => "common/discourse_javascript" %> + <%= preload_script 'browser-update' %> <%- unless customization_disabled? %> <%= raw theme_lookup("body_tag") %> diff --git a/config/application.rb b/config/application.rb index 9c23554c14..640f05f5b7 100644 --- a/config/application.rb +++ b/config/application.rb @@ -120,6 +120,7 @@ module Discourse google-tag-manager.js google-universal-analytics.js preload-application-data.js + authentication-complete.js } # Precompile all available locales