Logging a User Out - passport '/logout' now requires a callback function

What is your hint or solution suggestion?
There appears to have been a change to passport (in May 2022) and now ‘/logout’ requires a callback function - see stackoverflow here: javascript - Error: req#logout requires a callback function - Stack Overflow

I couldn’t pass the second part of this test with the sample code. So it only passed when I passed in the callback function like this:

    .get((req, res) => {
          req.logout(function(err) {
               if (err) { return next(err); }

If my understanding of the change is correct, I recommend changing the challenge text and the sample code to reflect this change in the library.

Here’s my Replit

Challenge: Logging a User Out

Link to the challenge:

Are you using the correct version of pug?

Edit, no you aren’t. You are using a later version than the first challenge in this series said that you need. Using different versions of packages than is specified will mean that the content in the challenges is not always going to work for you.

^I assume you meant passport and not pug.

As said, whenever you update a package version you have to expect potential breaking changes. Although, as this package (passport) has never released a major version the breaking change is behind a minor version update which isn’t ideal (going by SemVer anyway).

Given a version number MAJOR.MINOR.PATCH, increment the:

MAJOR version when you make incompatible API changes,
MINOR version when you add functionality in a backwards compatible manner, and
PATCH version when you make backwards compatible bug fixes.

1 Like

Woops, both actually.

I see that now, thanks.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.