diff options
author | Flam3rboy <34555296+Flam3rboy@users.noreply.github.com> | 2021-06-30 21:56:25 +0200 |
---|---|---|
committer | Flam3rboy <34555296+Flam3rboy@users.noreply.github.com> | 2021-06-30 21:56:25 +0200 |
commit | c187c4b7ac919f0f79afe965bf776bf4ee385493 (patch) | |
tree | afdfdee18149e65627bc8ec31be01fb8722a2f8a | |
parent | 1.3.21 (diff) | |
download | server-c187c4b7ac919f0f79afe965bf776bf4ee385493.tar.xz |
:sparkles: checkToken return user data
-rw-r--r-- | src/models/index.ts | 1 | ||||
-rw-r--r-- | src/util/checkToken.ts | 7 |
2 files changed, 6 insertions, 2 deletions
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<any> { 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 }); }); }); } |