summary refs log tree commit diff
path: root/src/util
diff options
context:
space:
mode:
authorFlam3rboy <34555296+Flam3rboy@users.noreply.github.com>2021-06-30 21:56:25 +0200
committerFlam3rboy <34555296+Flam3rboy@users.noreply.github.com>2021-06-30 21:56:25 +0200
commitc187c4b7ac919f0f79afe965bf776bf4ee385493 (patch)
treeafdfdee18149e65627bc8ec31be01fb8722a2f8a /src/util
parent1.3.21 (diff)
downloadserver-c187c4b7ac919f0f79afe965bf776bf4ee385493.tar.xz
:sparkles: checkToken return user data
Diffstat (limited to 'src/util')
-rw-r--r--src/util/checkToken.ts7
1 files changed, 5 insertions, 2 deletions
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 });
 		});
 	});
 }