diff options
Diffstat (limited to 'src/util/checkToken.ts')
-rw-r--r-- | src/util/checkToken.ts | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/util/checkToken.ts b/src/util/checkToken.ts index 73ffb670..4a60195b 100644 --- a/src/util/checkToken.ts +++ b/src/util/checkToken.ts @@ -9,7 +9,8 @@ export function checkToken(token: string, jwtSecret: string): Promise<any> { const user = await UserModel.findOne({ id: decoded.id }, { "user_data.valid_tokens_since": true }).exec(); if (!user) return rej("Invalid Token"); - if (decoded.iat * 1000 < user.user_data.valid_tokens_since.getTime()) return rej("Invalid Token"); + // we need to round it to seconds as it saved as seconds in jwt iat and valid_tokens_since is stored in milliseconds + if (decoded.iat * 1000 < user.user_data.valid_tokens_since.setSeconds(0, 0)) return rej("Invalid Token"); if (user.disabled) return rej("User disabled"); if (user.deleted) return rej("User not found"); |