stuyy / discord-oauth2-example

28 stars 9 forks source link

Error: req#logout requires a callback function (FIX) #7

Open Googool opened 2 years ago

Googool commented 2 years ago

This error can be fixed by replacing the following

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 :-)

Aritra67 commented 1 year ago

Thanks brother it worked

williamAdson commented 1 year ago

worked for me too😁 thanks