diff options
author | Madeline <46743919+MaddyUnderStars@users.noreply.github.com> | 2023-07-28 09:26:18 +1000 |
---|---|---|
committer | Madeline <46743919+MaddyUnderStars@users.noreply.github.com> | 2023-07-28 09:26:18 +1000 |
commit | f1f68c3d314c1b8bf42641a165ef6c9a8ebd348e (patch) | |
tree | 1a29ca81b1a4f5d7e71670821f2243f7a07cc32d /src/api | |
parent | Merge branch 'master' into feat/refactorIdentify (diff) | |
download | server-f1f68c3d314c1b8bf42641a165ef6c9a8ebd348e.tar.xz |
refactor checkToken
Diffstat (limited to 'src/api')
-rw-r--r-- | src/api/middlewares/Authentication.ts | 7 | ||||
-rw-r--r-- | src/api/routes/auth/reset.ts | 4 | ||||
-rw-r--r-- | src/api/routes/auth/verify/index.ts | 3 |
3 files changed, 3 insertions, 11 deletions
diff --git a/src/api/middlewares/Authentication.ts b/src/api/middlewares/Authentication.ts index d0e4d8a0..812888a3 100644 --- a/src/api/middlewares/Authentication.ts +++ b/src/api/middlewares/Authentication.ts @@ -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; diff --git a/src/api/routes/auth/reset.ts b/src/api/routes/auth/reset.ts index f97045a6..cb4f8180 100644 --- a/src/api/routes/auth/reset.ts +++ b/src/api/routes/auth/reset.ts @@ -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({ diff --git a/src/api/routes/auth/verify/index.ts b/src/api/routes/auth/verify/index.ts index a98c17fa..49f74277 100644 --- a/src/api/routes/auth/verify/index.ts +++ b/src/api/routes/auth/verify/index.ts @@ -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({ |