foundersandcoders / open-tourism-platform

An open platform to facilitate the creation of apps to promote local tourism and business in Nazareth
MIT License
17 stars 3 forks source link

Handle jwt-express errors #129

Open m4v15 opened 6 years ago

m4v15 commented 6 years ago

atm:

"The default behavior is to throw an error when the token is invalid, so you can add your custom logic to manage unauthorized access as follows:

app.use(function (err, req, res, next) {
  if (err.name === 'UnauthorizedError') {
    res.status(401).send('invalid token...');
  }
});

"

From the jwt-express docs

If a token is expired we probably want to direct them back to the log in page, or else we should render and nicer looking unauthorized page

mattlub commented 6 years ago

@m4v15 can we close?