The more I progress through the back-end part of the Full-Stack path, the more I realize the full aspect of the fiasco.
First of all, all of these lessons about sessions and passport.js and bcrypt are in the wrong place and should be BEFORE this portfolio project: E-Commerce App (REST API).
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Coming back to the subject at hand, this Dognation project is filled with ambiguity and mistakes.
Step 2 and 3 are talking about a verify callback named cb
which Iām guessing itās just the abbreviation of Callback:
Pass in a function with
username
,password
, and the verify callback,cb
, as its own parameters.
Make sure to add this function call within the function body of your local strategy:
passport.use(
new LocalStrategy(function (username, password, cb) {
// Call to the helper function here
})
);
CORRECTION:
That is NOT supposed to be cb
! Itās supposed to be done
. Like so:
passport.use(
new LocalStrategy(function (username, password, done) {
// Call to the helper function here
})
);
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
In step 10, it wants us to add done
as the second parameter of the callback of the helper function helper.findById
:
Pass in an the key used to find the user in the DB for the first parameter, and a function with
err
, anddone
as parameters for the second one.
CORRECTION:
You should add user
as the second parameter of that callback function and NOT done
. We already added done
in the callback of deserializeUser
. Like so:
passport.deserializeUser((id, done) => {
helper.findById(id, function (err, user) {
if (err) return done(err);
return done(null, user);
})
});
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
UNRESOLVED ISSUE:
In step 20, when I enter the password incorrectly, I expect to be redirected back to the login page. This endpoint is supposed to do that:
router.post(
"/login",
passport.authenticate("local", { failureRedirect: "/login" }),
(req, res) => {
res.redirect("../");
});
Yet I get an error in the browser saying that Cannot GET /login
Is anyone having the same issue?