DEV Community

Discussion on: A Step-by-Step Guide to Setting Up a Node.js API With Passport-JWT

Collapse
 
amoghtech profile image
Amoghtech

How to logout?

Collapse
 
osamuyi profile image
Osamuyi

Passport has a logout() function that when called, would terminate the user session.
It is attached to the request handler.

app.post('/logout', function(req, res, next){
req.logout(function(err) {
if (err) { return next(err); }
res.redirect('/');
});
});