refactor: hide invalid token error
This commit is contained in:
parent
5a7c437c70
commit
3bd7266dcf
@ -1,5 +1,5 @@
|
||||
import { Router } from 'express';
|
||||
import { header, body, validate } from '../middleware/validate';
|
||||
import { body, validate } from '../middleware/validate';
|
||||
import {
|
||||
authUser,
|
||||
authUserWithToken,
|
||||
@ -64,11 +64,15 @@ userRouter.post(
|
||||
throw new Error('Cannot get token');
|
||||
}
|
||||
|
||||
try {
|
||||
const user = await authUserWithToken(token);
|
||||
|
||||
const newToken = jwtSign(user);
|
||||
|
||||
res.json({ info: user, token: newToken });
|
||||
} catch (err) {
|
||||
res.status(401).json({ message: 'Invalid token' });
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user