XFE Git
XFE Studio Git
Git 首页 全局搜索
XFE 主站 文档 NuGet

SpaceNinjaServer

A simple server for a small space ninja game

公开
关注 0 Fork 1 Star 0
返回提交历史

XFEstudio/SpaceNinjaServer

chore: don't validate Nonce in query (#1341)

By asking MongoDB to simply find the account by the ID and then validating the nonce ourselves, we save roughly 1ms. Reviewed-on: https://onlyg.it/OpenWF/SpaceNinjaServer/pulls/1341

a6223939
Sainan <sainan@calamity.inc>
提交于

代码差异

1 个文件 +2 -5
Modified src/services/loginService.ts +2 -5
@@ -74,11 +74,8 @@ export const getAccountForRequest = async (req: Request): Promise<TAccountDocume
74 74 throw new Error("Request is missing nonce parameter");
75 75 }
76 76
77 const account = await Account.findOne({
78 _id: req.query.accountId,
79 Nonce: nonce
80 });
81 if (!account) {
77 const account = await Account.findById(req.query.accountId);
78 if (!account || account.Nonce != nonce) {
82 79 throw new Error("Invalid accountId-nonce pair");
83 80 }
84 81 if (account.Dropped && req.query.ct) {