From ad98f270c925e7cbdfdf7d7687605b49656503b6 Mon Sep 17 00:00:00 2001 From: Arpit Jalan Date: Sat, 5 Dec 2015 15:06:19 +0530 Subject: [PATCH] FIX: preserve redirect URL when logging in via social logins --- app/assets/javascripts/discourse/controllers/login.js.es6 | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/assets/javascripts/discourse/controllers/login.js.es6 b/app/assets/javascripts/discourse/controllers/login.js.es6 index 29db5b1d2ce..b2eed5ceed9 100644 --- a/app/assets/javascripts/discourse/controllers/login.js.es6 +++ b/app/assets/javascripts/discourse/controllers/login.js.es6 @@ -81,7 +81,7 @@ export default Ember.Controller.extend(ModalFunctionality, { 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')); - + if (ssoDestinationUrl) { $.cookie('sso_destination_url', null); window.location.assign(ssoDestinationUrl); @@ -203,10 +203,14 @@ 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) { // 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 {