How to use the express-jwt.UnauthorizedError function in express-jwt

To help you get started, we’ve selected a few express-jwt examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github olegabu / fabric-starter-rest / api.js View on Github external
app.use((req, res, next) => {
    if (req.user) {
      const login = req.user.sub;
      let client = mapFabricStarterClient[login];
      if (client) {
        logger.debug('cached client for', login);
        req.fabricStarterClient = client;
      } else {
        throw (new jwt.UnauthorizedError("No client context", {message: 'User is not logged in.'}));
      }
    }
    next();
  });

express-jwt

JWT authentication middleware.

MIT
Latest version published 2 years ago

Package Health Score

64 / 100
Full package analysis