Fixed redirection after auth

master
Keith Irwin 2017-04-19 00:13:57 -04:00
parent 192d66ca6f
commit 40808f8a05
No known key found for this signature in database
GPG Key ID: 378933C743E2BBC0
2 changed files with 6 additions and 16 deletions

View File

@ -20,14 +20,7 @@ module.exports = (app, passport) => {
failureFlash: true
},
loginCallback = (req,res)=>{
// Prevent redirect loop
if (req.session.next.substring(0,7)==='/login#'){
req.session.next = '#';
res.redirect('/map');
}
else {
res.redirect( req.session.next || '/map' );
}
res.redirect( req.session.next || '/map' );
};
// Login/-out
@ -45,13 +38,7 @@ module.exports = (app, passport) => {
app.get('/logout', (req,res)=>{
req.logout();
req.flash('success',`You have been logged out.`);
// Prevent redirect loop
if (req.session.next.substring(0,8)==='/logout#') {
req.session.next = '#';
res.redirect('/');
} else {
res.redirect(req.session.next || '/');
}
res.redirect( req.session.next || '/' );
});
// Signup

View File

@ -80,7 +80,10 @@ const
app.get( '*', (req,res,next)=>{
// Path for redirects
req.session.next = ( req.path.substring(0, req.path.indexOf('#')) || req.path )+'#';
let nextPath = ( req.path.substring(0, req.path.indexOf('#')) || req.path );
if ( nextPath!=='/login' && nextPath!=='/logout' ){
req.session.next = nextPath+'#';
}
// User account
res.locals.user = req.user;