auto(agent): Added error handling to auth middleware
This commit is contained in:
parent
29d1532c1f
commit
f03b758e18
107 changed files with 1962 additions and 1 deletions
|
|
@ -9,7 +9,7 @@ export const requireAuth = (req, res, next) => {
|
|||
try {
|
||||
req.user = jwt.verify(token, process.env.JWT_SECRET);
|
||||
next();
|
||||
} catch {
|
||||
} catch (err) {
|
||||
res.status(401).json({ error: 'Invalid token' });
|
||||
}
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue