SpaceNinjaServer/src/controllers/api/logoutController.ts

29 lines
701 B
TypeScript
Raw Normal View History

2023-06-01 17:08:05 -07:00
import { RequestHandler } from "express";
2024-05-28 13:45:06 +02:00
import { Account } from "@/src/models/loginModel";
2023-06-01 17:08:05 -07:00
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");
2024-05-28 13:45:06 +02:00
}
2023-06-01 17:08:05 -07:00
await Account.updateOne(
{
_id: req.query.accountId,
Nonce: nonce
},
{
Nonce: 0
}
);
2025-03-27 02:07:46 +01:00
res.writeHead(200, {
"Content-Type": "text/html",
"Content-Length": 1
});
res.end("1");
};