Let's say I am trying to access the path http://localhost:3000/users#/WyCrYc28r/foo/1414585518343
.
But the path /users
needs to be accessed only by the authenticated users as following:
app.get('/users', isLoggedIn, function (req, res) {
req.session.user = req.user;
res.cookie('uid', req.session.passport.user)
.render('users', { title: 'The Foo Machine', user: req.user });
});
And following is the isLoggedIn
middleware:
function isLoggedIn(req, res, next) {
if (req.isAuthenticated())
return next();
res.redirect('/login');
}
And following is how the login
is being handled:
app.post('/login', passport.authenticate('local-login', {
successRedirect: '/users',
failureRedirect: '/login',
failureFlash: true
}));
I get redirected to the http://localhost:3000/users
after logging in, but I want to the user to go to http://localhost:3000/users#/WyCrYc28r/foo/1414585518343
after successfully logging in as that was where the user wanted to go in the place place.
I am using PassportJS
module for authentication/authorization here and have the front end developed in AngularJS
.
Could somebody help me with it?