stuyy / discord-oauth2-example

28 stars 9 forks source link

Error: req#logout requires a callback function #9

Closed Googool closed 1 year ago

Googool commented 1 year ago

This will fix the following error - Error: req#logout requires a callback function, which occurs when trying to log out of the dashboard.

Replace the code below

router.get('/logout', (req, res) => {
    if(req.user) {
        req.logout();
        res.redirect('/');
    } else {
        res.redirect('/');
    }
});

With this

router.get('/logout', (req, res) => {
    if(req.user) {
        req.session.destroy();
        res.redirect('/');
    } else {
        res.redirect('/');
    }
});

Hope this will help someone :-)