From 7abd4687e2d80956d97a006c3a8b2411e1823b72 Mon Sep 17 00:00:00 2001 From: Arpit Jalan Date: Fri, 18 Sep 2015 18:29:57 +0530 Subject: [PATCH] FIX: redirect to original URL when logging in via OAuth --- app/assets/javascripts/discourse/controllers/login.js.es6 | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/assets/javascripts/discourse/controllers/login.js.es6 b/app/assets/javascripts/discourse/controllers/login.js.es6 index 824c3110f05..3297e1c0517 100644 --- a/app/assets/javascripts/discourse/controllers/login.js.es6 +++ b/app/assets/javascripts/discourse/controllers/login.js.es6 @@ -184,7 +184,12 @@ export default Ember.Controller.extend(ModalFunctionality, { // Reload the page if we're authenticated if (options.authenticated) { - if (window.location.pathname === Discourse.getURL('/login')) { + const destinationUrl = $.cookie('destination_url'); + if (self.get('loginRequired') && destinationUrl) { + // redirect client to the original URL + $.cookie('destination_url', null); + window.location.href = destinationUrl; + } else if (window.location.pathname === Discourse.getURL('/login')) { window.location.pathname = Discourse.getURL('/'); } else { window.location.reload();