jwt.js 262 B

12345678910111213
  1. export default function () {
  2. return (req, res, next) => {
  3. if (req.headers.authorization) {
  4. const 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. }