diff --git a/src/models/index.ts b/src/models/index.ts index 004095db..4cc6ec2b 100644 --- a/src/models/index.ts +++ b/src/models/index.ts @@ -35,3 +35,4 @@ export * from "./Status"; export * from "./Role"; export * from "./User"; export * from "./VoiceState"; +export * from "./RateLimit"; diff --git a/src/util/checkToken.ts b/src/util/checkToken.ts index d890e0e1..e021a406 100644 --- a/src/util/checkToken.ts +++ b/src/util/checkToken.ts @@ -8,14 +8,17 @@ export function checkToken(token: string, jwtSecret: string): Promise { jwt.verify(token, jwtSecret, JWTOptions, async (err, decoded: any) => { if (err || !decoded) return rej("Invalid Token"); - const user = await UserModel.findOne({ id: decoded.id }, { "user_data.valid_tokens_since": true }).exec(); + const user = await UserModel.findOne( + { id: decoded.id }, + { "user_data.valid_tokens_since": true, bot: true } + ).exec(); if (!user) 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"); - return res(decoded); + return res({ decoded, user }); }); }); }