diff --git a/public/src/ajaxify.js b/public/src/ajaxify.js
index 1421b494b1..95619b4ffb 100644
--- a/public/src/ajaxify.js
+++ b/public/src/ajaxify.js
@@ -111,9 +111,10 @@ var ajaxify = {};
return href == 'javascript:;' || href == window.location.href + "#" || href.slice(-1) === "#";
}
- if (hrefEmpty(this.href)) return;
- if (this.target !== '') return;
- if (this.protocol === 'javascript:') return;
+ if (hrefEmpty(this.href) || this.target !== '' || this.protocol === 'javascript:')
+ return;
+
+ app.previousUrl = window.location.href;
if (!e.ctrlKey && e.which === 1) {
if (this.host === window.location.host) {
@@ -121,6 +122,7 @@ var ajaxify = {};
var url = this.href.replace(rootUrl + '/', '');
if (ajaxify.go(url)) {
+
e.preventDefault();
}
} else if (window.location.pathname !== '/outgoing') {
diff --git a/public/src/forum/register.js b/public/src/forum/register.js
index da83144674..e485f4960f 100644
--- a/public/src/forum/register.js
+++ b/public/src/forum/register.js
@@ -11,6 +11,8 @@
validationError = false,
successIcon = '';
+ $('#referrer').val(app.previousUrl);
+
function showError(element, msg) {
element.html(msg);
element.parent()
diff --git a/public/templates/register.tpl b/public/templates/register.tpl
index 6003d203f9..7184f0d3a4 100644
--- a/public/templates/register.tpl
+++ b/public/templates/register.tpl
@@ -65,6 +65,7 @@
+
diff --git a/src/routes/authentication.js b/src/routes/authentication.js
index 8169758688..e4a69623b0 100644
--- a/src/routes/authentication.js
+++ b/src/routes/authentication.js
@@ -183,7 +183,10 @@
req.login({
uid: uid
}, function() {
- res.redirect(nconf.get('relative_path') + '/');
+ if(req.body.referrer)
+ res.redirect(req.body.referrer);
+ else
+ res.redirect(nconf.get('relative_path') + '/');
});
} else {
res.redirect(nconf.get('relative_path') + '/register');