SpaceNinjaServer/src/controllers/api/logoutController.ts
Sainan b2423f5d41
All checks were successful
Build / build (18) (push) Successful in 1m15s
Build / build (20) (push) Successful in 58s
Build / build (18) (pull_request) Successful in 1m15s
Build / build (22) (push) Successful in 1m18s
Build / build (20) (pull_request) Successful in 1m8s
Build / build (22) (pull_request) Successful in 1m11s
keep response as-is
2025-03-27 02:07:46 +01:00

29 lines
701 B
TypeScript

import { RequestHandler } from "express";
import { Account } from "@/src/models/loginModel";
export const logoutController: 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
},
{
Nonce: 0
}
);
res.writeHead(200, {
"Content-Type": "text/html",
"Content-Length": 1
});
res.end("1");
};