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
|
|
|
|
2025-03-27 02:05:34 +01: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
|
|
|
|
2025-03-27 02:05:34 +01: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");
|
2025-03-27 02:05:34 +01:00
|
|
|
};
|