Fix to make page refresh on logout
This commit is contained in:
@@ -246,17 +246,21 @@ app.get('/home', (req, res) => {
|
||||
const loggedIn = req.session.user ? true : false;
|
||||
res.render('pages/home');
|
||||
});
|
||||
|
||||
app.get('/logout', (req, res) => {
|
||||
req.session.destroy(err => {
|
||||
if (err) {
|
||||
console.error('Error destroying session:', err);
|
||||
res.status(500).send('Internal Server Error');
|
||||
} 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
|
||||
*************************/
|
||||
|
||||
Reference in New Issue
Block a user