@ -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;
@ -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) {