refactor checkToken

This commit is contained in:
Madeline
2023-07-28 09:26:18 +10:00
parent 8a3989c297
commit f1f68c3d31
8 changed files with 75 additions and 125 deletions
+1 -6
View File
@@ -92,12 +92,7 @@ export async function Authentication(
Sentry.setUser({ id: req.user_id });
try {
const { jwtSecret } = Config.get().security;
const { decoded, user } = await checkToken(
req.headers.authorization,
jwtSecret,
);
const { decoded, user } = await checkToken(req.headers.authorization);
req.token = decoded;
req.user_id = decoded.id;
+1 -3
View File
@@ -48,11 +48,9 @@ router.post(
async (req: Request, res: Response) => {
const { password, token } = req.body as PasswordResetSchema;
const { jwtSecret } = Config.get().security;
let user;
try {
const userTokenData = await checkToken(token, jwtSecret, true);
const userTokenData = await checkToken(token);
user = userTokenData.user;
} catch {
throw FieldErrors({
+1 -2
View File
@@ -78,11 +78,10 @@ router.post(
}
}
const { jwtSecret } = Config.get().security;
let user;
try {
const userTokenData = await checkToken(token, jwtSecret, true);
const userTokenData = await checkToken(token);
user = userTokenData.user;
} catch {
throw FieldErrors({