From ef47f3fd157bfa82239a596d02e41a8adcc513f9 Mon Sep 17 00:00:00 2001 From: Andrew Darqui Date: Sun, 6 Oct 2013 04:17:06 -0400 Subject: [PATCH 1/3] if nodebb returns 403/404, don't overwrite previousUrl. If you don't do this, when logging in after a 403/404, it will redirect you to the 403/404 page. --- public/src/ajaxify.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/public/src/ajaxify.js b/public/src/ajaxify.js index 7b8cf215fb..2d0ddc273a 100644 --- a/public/src/ajaxify.js +++ b/public/src/ajaxify.js @@ -117,7 +117,8 @@ var ajaxify = {}; if (hrefEmpty(this.href) || this.target !== '' || this.protocol === 'javascript:') return; - app.previousUrl = window.location.href; + if(window.location.pathname != '/403' && window.location.pathname != '/404') + app.previousUrl = window.location.href; if (!e.ctrlKey && e.which === 1) { if (this.host === window.location.host) { @@ -192,4 +193,4 @@ var ajaxify = {}; } } -}(jQuery)); \ No newline at end of file +}(jQuery)); From b2e81b5d1780ef4cafaba3e83ece6c515d783d4c Mon Sep 17 00:00:00 2001 From: Andrew Darqui Date: Sun, 6 Oct 2013 04:24:38 -0400 Subject: [PATCH 2/3] Fixes a small issue with the redirect after logging in. If app.previousUrl is undefined (from accessing the page directly), login would fail to redirect you because of an error with indexOf on the undefined app.previousUrl. --- public/src/forum/login.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/public/src/forum/login.js b/public/src/forum/login.js index ed4e0753f6..96e6c49e94 100644 --- a/public/src/forum/login.js +++ b/public/src/forum/login.js @@ -35,6 +35,9 @@ define(function() { $('#login-error-notify').show(); } else { $('#login-error-notify').hide(); + + if(!app.previousUrl) { app.previousUrl = '/'; } + if(app.previousUrl.indexOf('/reset/') != -1) window.location.replace(RELATIVE_PATH + "/?loggedin"); else @@ -63,4 +66,4 @@ define(function() { }; return Login; -}); \ No newline at end of file +}); From 4b0e9156986e2dcb23f760783d6fd408ccef3a51 Mon Sep 17 00:00:00 2001 From: Andrew Darqui Date: Sun, 6 Oct 2013 04:32:03 -0400 Subject: [PATCH 3/3] just changed the 403/404 checking logic to use regex. --- public/src/ajaxify.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/src/ajaxify.js b/public/src/ajaxify.js index 2d0ddc273a..81344db292 100644 --- a/public/src/ajaxify.js +++ b/public/src/ajaxify.js @@ -117,7 +117,7 @@ var ajaxify = {}; if (hrefEmpty(this.href) || this.target !== '' || this.protocol === 'javascript:') return; - if(window.location.pathname != '/403' && window.location.pathname != '/404') + if(!window.location.pathname.match(/\/(403|404)$/g)) app.previousUrl = window.location.href; if (!e.ctrlKey && e.which === 1) {