Answers for "ejs jwt authentication"

0

ejs jwt authentication

const cookieParser = require('cookie-parser')

const withAuthUserId = [
  cookieParser(),
  (req, res, next) => {
    const claims = jsonwebtoken.verify(req.cookies['jwt'], jwtKey)
    req['authUserId'] = claims['sub']
    next()
  }
]

app.get('/api/auth-user', ...withAuthUserId, (req, res) => {
  /* See: req['authUserId'] */
})
Posted by: Guest on May-19-2021

Code answers related to "ejs jwt authentication"

Browse Popular Code Answers by Language