From 15d5175f8dda41b861140e22a768cfea7e625b8b Mon Sep 17 00:00:00 2001 From: Anjali Deep <45489595+anjali142@users.noreply.github.com> Date: Sat, 22 Jun 2019 20:58:22 +0530 Subject: [PATCH 1/2] Redirecting to previous page after login(#105) Issue #105 Changes are done in auth.js file of the controls section Changes are done in order to redirect to previous page after login action express-back uses sessions to track the previous path the user visits res.redirect('back') redirects to URL of the previous page that the express-back gives Fixes: #105 --- controls/auth.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/controls/auth.js b/controls/auth.js index 6bef8d91..3707a76a 100644 --- a/controls/auth.js +++ b/controls/auth.js @@ -2,6 +2,7 @@ var passport = require('passport'); var user = require('../models/users'); var submissions = require('../models/submission'); var moment = require("moment"); +var back = require("express-back"); /**POST: user signup * route: /user/signup @@ -78,7 +79,7 @@ exports.postLogin = function (req, res) { */ exports.getLogout = function (req, res) { req.logout(); - res.redirect('/'); + res.redirect('back'); } /**Implementing the routing guards */ From 714821e5dbeeadb96f492d880b192fcd5cac0e55 Mon Sep 17 00:00:00 2001 From: Anjali Deep <45489595+anjali142@users.noreply.github.com> Date: Sun, 30 Jun 2019 19:37:20 +0530 Subject: [PATCH 2/2] Redirecting to previous page after login(#105) --- controls/auth.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/controls/auth.js b/controls/auth.js index 3707a76a..7afa3f92 100644 --- a/controls/auth.js +++ b/controls/auth.js @@ -2,12 +2,12 @@ var passport = require('passport'); var user = require('../models/users'); var submissions = require('../models/submission'); var moment = require("moment"); -var back = require("express-back"); /**POST: user signup * route: /user/signup */ exports.postSignUp = function (req, res) { + var url = req.url; user.findOne({ username: req.body.username }) .then((data) => { console.log(data); @@ -79,7 +79,7 @@ exports.postLogin = function (req, res) { */ exports.getLogout = function (req, res) { req.logout(); - res.redirect('back'); + res.redirect('url'); } /**Implementing the routing guards */