I am being able to logout successfully, but the else part of the code does not come into play even when I browse /logout successfully.
router.get('/logout',(req,res)=>{
if(req.session){
req.session.destroy();
res.clearCookie('session-id');
res.redirect('/');
}
else{
var err = new Error('You are not logged in!');
err.status = 403;
next(err);
}
});
Expectation: After logging out, the next time when a user requests /logout they should receive the reply specified in the else part, i.e. "You are not logged in!"
Aucun commentaire:
Enregistrer un commentaire