londonappbrewery / Authentication-Secrets

Companion Code for the Authentication Module on The Complete 2019 Web Development Bootcamp
https://www.appbrewery.co
440 stars 525 forks source link

Unable to retrieve req.user.id app.post("/submit") #22

Open Sakthilab opened 2 years ago

Sakthilab commented 2 years ago

when i try to click submit the secret it is not getting the user id

when i checked using console.log(req.user.id) it is showing "undefined"

facing isse with app.post("/submit")

DerekGray2022 commented 2 years ago

I had this the same problem with app.post("/submit). It turned out to be an error with my submittedSecret constant.

I had => const submittedSecret = req.body.submit; when I should've had => const submittedSecret = req.body.secret;

This may (or may not) be the same issue you're getting.

regan-mu commented 2 years ago

Another cause for the problem would be returning the user id during serialization: passport.serializeUser(function(user, cb) { process.nextTick(function() { return cb(null, { id: user.id, username: user.username }); }); }); Read More Here => https://www.passportjs.org/concepts/authentication/sessions/

yourHighness11 commented 1 year ago

when i try to click submit the secret it is not getting the user id

when i checked using console.log(req.user.id) it is showing "undefined"

facing isse with app.post("/submit")

just use console.log(req.user) you will get the id of the user.....

and copy the sessions from the link given below:-

https://www.passportjs.org/concepts/authentication/downloads/html/