fix: handle 'Invalid accountId-nonce pair' error for all controllers
This commit is contained in:
parent
28926d1d30
commit
dd6b7ee4ef
@ -18,13 +18,7 @@ import {
|
|||||||
import { handleSubsumeCompletion } from "./infestedFoundryController";
|
import { handleSubsumeCompletion } from "./infestedFoundryController";
|
||||||
|
|
||||||
export const inventoryController: RequestHandler = async (request, response) => {
|
export const inventoryController: RequestHandler = async (request, response) => {
|
||||||
let account;
|
const account = await getAccountForRequest(request);
|
||||||
try {
|
|
||||||
account = await getAccountForRequest(request);
|
|
||||||
} catch (e) {
|
|
||||||
response.status(400).send("Log-in expired");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const inventory = await Inventory.findOne({ accountOwnerId: account._id.toString() })
|
const inventory = await Inventory.findOne({ accountOwnerId: account._id.toString() })
|
||||||
.populate<{ LoadOutPresets: ILoadoutDatabase }>("LoadOutPresets")
|
.populate<{ LoadOutPresets: ILoadoutDatabase }>("LoadOutPresets")
|
||||||
|
@ -2,7 +2,9 @@ import { NextFunction, Request, Response } from "express";
|
|||||||
import { logger } from "../utils/logger";
|
import { logger } from "../utils/logger";
|
||||||
|
|
||||||
export const errorHandler = (err: Error, req: Request, res: Response, _next: NextFunction): void => {
|
export const errorHandler = (err: Error, req: Request, res: Response, _next: NextFunction): void => {
|
||||||
if (err.stack) {
|
if (err.message == "Invalid accountId-nonce pair") {
|
||||||
|
res.status(400).json("Log-in expired");
|
||||||
|
} else if (err.stack) {
|
||||||
const stackArr = err.stack.split("\n");
|
const stackArr = err.stack.split("\n");
|
||||||
stackArr[0] += ` while processing ${req.path} request`;
|
stackArr[0] += ` while processing ${req.path} request`;
|
||||||
logger.error(stackArr.join("\n"));
|
logger.error(stackArr.join("\n"));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user