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

improve: say the magic words to log the client out when nonce is invalidated (#250)

17244ea3
Sainan <sainan@calamity.gg>
提交于

代码差异

2 个文件 +9 -9
Modified src/controllers/api/getCreditsController.ts +8 -2
@@ -5,6 +5,14 @@ import { getInventory } from "@/src/services/inventoryService";
5 5
6 6 // eslint-disable-next-line @typescript-eslint/no-misused-promises
7 7 export const getCreditsController: RequestHandler = async (req, res) => {
8 let accountId;
9 try {
10 accountId = await getAccountIdForRequest(req);
11 } catch (e) {
12 res.status(400).send("Log-in expired");
13 return;
14 }
15
8 16 if (config.infiniteResources) {
9 17 res.json({
10 18 RegularCredits: 999999999,
@@ -15,8 +23,6 @@ export const getCreditsController: RequestHandler = async (req, res) => {
15 23 return;
16 24 }
17 25
18 const accountId = await getAccountIdForRequest(req);
19
20 26 const inventory = await getInventory(accountId);
21 27 res.json({
22 28 RegularCredits: inventory.RegularCredits,
Modified src/controllers/api/inventoryController.ts +1 -7
@@ -17,13 +17,7 @@ const inventoryController: RequestHandler = async (request: Request, response: R
17 17 try {
18 18 accountId = await getAccountIdForRequest(request);
19 19 } catch (e) {
20 if ((e as Error).message == "Invalid accountId-nonce pair") {
21 // TODO: Figure out some way to tell the game to stop trying with this nonce.
22 // For now, we'll have to be a little nasty.
23 response.destroy();
24 return;
25 }
26 response.status(400).json({ error: (e as Error).message });
20 response.status(400).send("Log-in expired");
27 21 return;
28 22 }
29 23