SpaceNinjaServer/src/controllers/custom/ircDroppedController.ts
Sainan 7f5592e00c
Some checks failed
Build / build (18) (push) Has been cancelled
Build / build (20) (push) Has been cancelled
Build / build (22) (push) Waiting to run
Build Docker image / docker (push) Waiting to run
chore: improve authentication and Dropped logic (#1296)
- Dropped is now also unset by getAccountForRequest
- Improved how nonce is validated to avoid possible parser mismatch issues to smuggle a 0
- Updated ircDroppedController to perform only a single MongoDB operation

Reviewed-on: #1296
2025-03-23 09:05:47 -07:00

25 lines
609 B
TypeScript

import { Account } from "@/src/models/loginModel";
import { RequestHandler } from "express";
export const ircDroppedController: RequestHandler = async (req, res) => {
if (!req.query.accountId) {
throw new Error("Request is missing accountId parameter");
}
const nonce: number = parseInt(req.query.nonce as string);
if (!nonce) {
throw new Error("Request is missing nonce parameter");
}
await Account.updateOne(
{
_id: req.query.accountId,
Nonce: nonce
},
{
Dropped: true
}
);
res.end();
};