Skip to content

Node.js based forum software built for the modern web

property fixed #2087

Julian Lamb5481ceed20b
diff --git a/public/src/client/login.js b/public/src/client/login.js
index c4600c36ac..e7079ddfed 100644
--- a/public/src/client/login.js
+++ b/public/src/client/login.js
@@ -33,6 +33,16 @@ define('forum/login', function() {
});
$('#content #username').focus();
+
+ // Add "returnTo" data if present
+ if (app.previousUrl) {
+ var returnToEl = document.createElement('input');
+ returnToEl.type = 'hidden';
+ returnToEl.name = 'returnTo';
+ returnToEl.value = app.previousUrl.replace(window.location.origin + RELATIVE_PATH, '');
+ $(returnToEl).appendTo(formEl);
+ console.log('appended');
+ }
};
return Login;
diff --git a/src/routes/authentication.js b/src/routes/authentication.js
index c405649f66..edd984bc4b 100644
--- a/src/routes/authentication.js
+++ b/src/routes/authentication.js
@@ -83,6 +83,11 @@
return res.status(404).send('');
}
+ // Handle returnTo data
+ if (req.body.hasOwnProperty('returnTo') && !req.session.returnTo) {
+ req.session.returnTo = req.body.returnTo;
+ }
+
if (req.body.username && utils.isEmailValid(req.body.username)) {
user.getUsernameByEmail(req.body.username, function(err, username) {
if (err) {