May 2018
Intermediate to advanced
470 pages
13h 54m
English
The requireSignin method in auth.controller.js uses express-jwt to verify that the incoming request has a valid JWT in the Authorization header. If the token is valid, it appends the verified user's ID in an 'auth' key to the request object, otherwise it throws an authentication error.
mern-skeleton/server/controllers/auth.controller.js:
const requireSignin = expressJwt({ secret: config.jwtSecret, userProperty: 'auth'})
We can add requireSignin to any route that should be protected against unauthenticated access.
Read now
Unlock full access