FrontendMasters/api-design-node-v2

Where is verifyUser invoked?

corderophi678 opened this issue · 2 comments

In /src/api/modules/auth.js the signin function has a comment that says "req.user will be there from the middleware verify user." But it's unclear to me where verifyUser is invoked in order to put the user's id on the req object. Any help would be super appreciated.

I use it like so app.use('/signin', verifyUser(), signin) in place of this line

app.use('/signin', signin)

Auth is actually quite broken but luckily the instructor doesn't use it, he just bypasses it by creating a new user or disabling auth altogether.

Check out my branch if you want to see how I got auth to work. I had to replace bcrypt with bcryptjs npm package as it was complaining it couldn't find bcrypt_lib.node whenever I tried to import it. This seems to be caused by bcrypt not being able to download a precompiled bcrypt lib and the fallback failing to build from source.

thanks @timiscoding . You'll have to use it as middleware in your route for auth like @timiscoding said @corderophi678 .