Trouble Authenticating in my Advanced Node Pug App

I am about 2/3rds throug the chapter and i am at a point where i should be able to log into my app and see the profiles but it is failing.

I started logging at different stages and i think i know where it is failing. I believe it is at my ensureauthenticated function in my routes.js file.

what i cant figure out is why it is not getting authenticated.

Side note, if i stop and restart my app, i get a ‘get’ failure message. I have to refresh the whole website. I do not know if the two are related.

Asking for help identifying where my code is breaking down.

I think ive narrowed it down. When i register a user, it is creating user, then hashing a password and storing it in Mongo.

I think the failure is either in the deserialization or in the actual authentication of bcrypt.

any advice on where to go next? I am searching through those functions and routes and not finding any clear problems

I just went through the entire advanced express course again and stumped again at authenticating.

My github authenticating is throwing an error and my local again is not authenticating.

I can see i am writing a new user with a hashed pw. It has to be how its coming bcak and being handled.

this time through i understood a hell of a lot more but still cant get either. Ive read passport, mongo, bcrypt, pasport-session wensite’s documents (as much as i thought pertained to what i am doing now) but landed exactly where i was.

Weird thing is that all my tests pass.

Robs 2nd replit for advanced express