Fix to make page refresh on logout

This commit is contained in:
Lucas Patenaude
2024-04-23 23:11:21 -06:00
parent 255999453e
commit 033c73bb01
2 changed files with 5 additions and 1 deletions

View File

@@ -246,17 +246,21 @@ app.get('/home', (req, res) => {
const loggedIn = req.session.user ? true : false; const loggedIn = req.session.user ? true : false;
res.render('pages/home'); res.render('pages/home');
}); });
app.get('/logout', (req, res) => { app.get('/logout', (req, res) => {
req.session.destroy(err => { req.session.destroy(err => {
if (err) { if (err) {
console.error('Error destroying session:', err); console.error('Error destroying session:', err);
res.status(500).send('Internal Server Error'); res.status(500).send('Internal Server Error');
} else { } else {
res.render('pages/home', { message: 'Logged out Successfully' }); // Redirect to the same page after destroying the session
res.redirect('/'); // You can change '/' to the desired page if it's not the home page
} }
}); });
}); });
/************************ /************************
League Page Routes League Page Routes
*************************/ *************************/