From fd2cd63b0844a1ab9755c21c7dc3e27cd9a7f6dc Mon Sep 17 00:00:00 2001 From: Leo McArdle Date: Mon, 28 Aug 2017 17:40:31 +0100 Subject: [PATCH] FIX: make /new-topic redirect survive full screen login (#5105) --- .../javascripts/discourse/controllers/login.js.es6 | 10 +--------- .../javascripts/discourse/routes/new-message.js.es6 | 2 +- .../javascripts/discourse/routes/new-topic.js.es6 | 2 +- 3 files changed, 3 insertions(+), 11 deletions(-) diff --git a/app/assets/javascripts/discourse/controllers/login.js.es6 b/app/assets/javascripts/discourse/controllers/login.js.es6 index 38ea5f9d304..a42f4233c42 100644 --- a/app/assets/javascripts/discourse/controllers/login.js.es6 +++ b/app/assets/javascripts/discourse/controllers/login.js.es6 @@ -90,7 +90,6 @@ export default Ember.Controller.extend(ModalFunctionality, { // Trigger the browser's password manager using the hidden static login form: const $hidden_login_form = $('#hidden-login-form'); const destinationUrl = $.cookie('destination_url'); - const shouldRedirectToUrl = self.session.get("shouldRedirectToUrl"); const ssoDestinationUrl = $.cookie('sso_destination_url'); $hidden_login_form.find('input[name=username]').val(self.get('loginName')); $hidden_login_form.find('input[name=password]').val(self.get('loginPassword')); @@ -103,9 +102,6 @@ export default Ember.Controller.extend(ModalFunctionality, { // redirect client to the original URL $.cookie('destination_url', null); $hidden_login_form.find('input[name=redirect]').val(destinationUrl); - } else if (shouldRedirectToUrl) { - self.session.set("shouldRedirectToUrl", null); - $hidden_login_form.find('input[name=redirect]').val(shouldRedirectToUrl); } else { $hidden_login_form.find('input[name=redirect]').val(window.location.href); } @@ -222,14 +218,10 @@ export default Ember.Controller.extend(ModalFunctionality, { // Reload the page if we're authenticated if (options.authenticated) { const destinationUrl = $.cookie('destination_url'); - const shouldRedirectToUrl = self.session.get("shouldRedirectToUrl"); - if (self.get('loginRequired') && destinationUrl) { + if (destinationUrl) { // redirect client to the original URL $.cookie('destination_url', null); window.location.href = destinationUrl; - } else if (shouldRedirectToUrl) { - self.session.set("shouldRedirectToUrl", null); - window.location.href = shouldRedirectToUrl; } else if (window.location.pathname === Discourse.getURL('/login')) { window.location.pathname = Discourse.getURL('/'); } else { diff --git a/app/assets/javascripts/discourse/routes/new-message.js.es6 b/app/assets/javascripts/discourse/routes/new-message.js.es6 index 5010077a751..06d929c552c 100644 --- a/app/assets/javascripts/discourse/routes/new-message.js.es6 +++ b/app/assets/javascripts/discourse/routes/new-message.js.es6 @@ -33,7 +33,7 @@ export default Discourse.Route.extend({ } }); } else { - this.session.set("shouldRedirectToUrl", window.location.href); + $.cookie('destination_url', window.location.href); this.replaceWith('login'); } } diff --git a/app/assets/javascripts/discourse/routes/new-topic.js.es6 b/app/assets/javascripts/discourse/routes/new-topic.js.es6 index 53336a67f27..88dcd61368e 100644 --- a/app/assets/javascripts/discourse/routes/new-topic.js.es6 +++ b/app/assets/javascripts/discourse/routes/new-topic.js.es6 @@ -13,7 +13,7 @@ export default Discourse.Route.extend({ }); } else { // User is not logged in - self.session.set("shouldRedirectToUrl", window.location.href); + $.cookie('destination_url', window.location.href); self.replaceWith('login'); } }