DEV Community

Discussion on: Set up JWT authentication in MERN from scratch

Collapse
 
jeffreythecoder profile image
Jeffrey Yu • Edited

/user/info should pass through the auth middleware and I just added it. The auth middleware decodes the user payload in jwt to req.user, and the fetched user info should have the same user id as req.user.id.

Essentially a user can only get the user info with a given token, not an id.