u/im_shashikanthin r/node • Recommends
On “Need help in implementing JWT authentication”
Instead of using passport just use jsonwebtoken module which is very simple to implement and has a lot less code. You can follow this guide.
Store the token in a cookie and set the httpOnly flag to true on login. Normally you would want to store the user id as the payload while signing the token. On subsequent requests the cookie will automatically be sent back to the server which you can then parse and verify for validity, grab the user id and serve the request accordingly.
Hope this helps