improve: say the magic words to log the client out when nonce is invalidated (#250)
This commit is contained in:
parent
4f1e5ff326
commit
17244ea390
@ -5,6 +5,14 @@ import { getInventory } from "@/src/services/inventoryService";
|
|||||||
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-misused-promises
|
// eslint-disable-next-line @typescript-eslint/no-misused-promises
|
||||||
export const getCreditsController: RequestHandler = async (req, res) => {
|
export const getCreditsController: RequestHandler = async (req, res) => {
|
||||||
|
let accountId;
|
||||||
|
try {
|
||||||
|
accountId = await getAccountIdForRequest(req);
|
||||||
|
} catch (e) {
|
||||||
|
res.status(400).send("Log-in expired");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (config.infiniteResources) {
|
if (config.infiniteResources) {
|
||||||
res.json({
|
res.json({
|
||||||
RegularCredits: 999999999,
|
RegularCredits: 999999999,
|
||||||
@ -15,8 +23,6 @@ export const getCreditsController: RequestHandler = async (req, res) => {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const accountId = await getAccountIdForRequest(req);
|
|
||||||
|
|
||||||
const inventory = await getInventory(accountId);
|
const inventory = await getInventory(accountId);
|
||||||
res.json({
|
res.json({
|
||||||
RegularCredits: inventory.RegularCredits,
|
RegularCredits: inventory.RegularCredits,
|
||||||
|
@ -17,13 +17,7 @@ const inventoryController: RequestHandler = async (request: Request, response: R
|
|||||||
try {
|
try {
|
||||||
accountId = await getAccountIdForRequest(request);
|
accountId = await getAccountIdForRequest(request);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if ((e as Error).message == "Invalid accountId-nonce pair") {
|
response.status(400).send("Log-in expired");
|
||||||
// TODO: Figure out some way to tell the game to stop trying with this nonce.
|
|
||||||
// For now, we'll have to be a little nasty.
|
|
||||||
response.destroy();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
response.status(400).json({ error: (e as Error).message });
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user