Redirecting to previous page after login(#105)#119
Redirecting to previous page after login(#105)#119anjali142 wants to merge 2 commits intoKamandPrompt:masterfrom
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
| 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.
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.
Try getting the current url in the req param and then redirect back to that url after calling the logout function.
Vishal1541
left a comment
There was a problem hiding this comment.
@anjali142 This doesn't seem to work. Can you check it again and make the necessary changes.
| * route: /user/signup | ||
| */ | ||
| exports.postSignUp = function (req, res) { | ||
| var url = req.url; |
There was a problem hiding this comment.
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
| exports.getLogout = function (req, res) { | ||
| req.logout(); | ||
| res.redirect('/'); | ||
| res.redirect('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