2023-06-01 17:08:05 -07:00
|
|
|
import { RequestHandler } from "express";
|
2024-05-28 13:45:06 +02:00
|
|
|
import { getAccountIdForRequest } from "@/src/services/loginService";
|
|
|
|
import { Account } from "@/src/models/loginModel";
|
2023-06-01 17:08:05 -07:00
|
|
|
|
2024-05-28 13:45:06 +02:00
|
|
|
const logoutController: RequestHandler = async (req, res) => {
|
|
|
|
const accountId = await getAccountIdForRequest(req);
|
2025-03-24 14:30:08 +01:00
|
|
|
const account = await Account.findById(accountId);
|
2024-05-28 13:45:06 +02:00
|
|
|
if (account) {
|
|
|
|
account.Nonce = 0;
|
2024-06-01 13:03:27 +02:00
|
|
|
await account.save();
|
2024-05-28 13:45:06 +02:00
|
|
|
}
|
2023-06-01 17:08:05 -07:00
|
|
|
res.writeHead(200, {
|
|
|
|
"Content-Type": "text/html",
|
2023-06-03 19:24:57 -07:00
|
|
|
"Content-Length": 1
|
2023-06-01 17:08:05 -07:00
|
|
|
});
|
2023-06-03 19:24:57 -07:00
|
|
|
res.end("1");
|
2023-06-01 17:08:05 -07:00
|
|
|
};
|
|
|
|
|
2023-06-02 00:20:49 -03:00
|
|
|
export { logoutController };
|