jwt.js 269 B

12345678910111213
  1. module.exports = function () {
  2. return function (req, res, next) {
  3. if (req.headers.authorization) {
  4. let parts = req.headers.authorization.split(' ');
  5. if (parts && parts[0] === 'Bearer' && parts[1]) {
  6. res.locals.token = parts[1];
  7. }
  8. }
  9. next();
  10. };
  11. };