Skip to content

Commit

Permalink
fix(erros-middleware): return unauthorized code when token is expired (
Browse files Browse the repository at this point in the history
  • Loading branch information
William-Reticena authored Mar 20, 2024
1 parent 85093c5 commit 9ef4bf7
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/middlewares/erros-middleware.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,18 @@ export default (error, request, response, next) => {
return;
}

if (error.name === 'TokenExpiredError') {
response.status(401)
.json({
error: {
code: 401,
message: 'Token expirado',
},
});

return;
}

response.status(500)
.json({
error: {
Expand Down

0 comments on commit 9ef4bf7

Please sign in to comment.