-
Notifications
You must be signed in to change notification settings - Fork 58
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Redirecting to previous page after login(#105) #119
base: master
Are you sure you want to change the base?
Conversation
Issue KamandPrompt#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: KamandPrompt#105
Good job @anjali142 , but you're adding a new package called |
controls/auth.js
Outdated
@@ -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"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
New module should not be added.
@@ -78,7 +79,7 @@ exports.postLogin = function (req, res) { | |||
*/ | |||
exports.getLogout = function (req, res) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Try getting the current url in the req
param and then redirect back to that url after calling the logout function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@anjali142 This doesn't seem to work. Can you check it again and make the necessary changes.
@@ -7,6 +7,7 @@ var moment = require("moment"); | |||
* route: /user/signup | |||
*/ | |||
exports.postSignUp = function (req, res) { | |||
var url = req.url; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
req.url is only supported for requests received through http server
It is not from express
try req.headers.referer
this way you will also get the query parameters
@@ -78,7 +79,7 @@ exports.postLogin = function (req, res) { | |||
*/ | |||
exports.getLogout = function (req, res) { | |||
req.logout(); | |||
res.redirect('/'); | |||
res.redirect('url'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
url instead of 'url'
What's this PR do? (related issue if exists)
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
Any context you want to provide on the implementation?
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