SpaceNinjaServer/src/controllers/api/logoutController.ts

21 lines
639 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 { getAccountIdForRequest } from "@/src/services/loginService";
import { Account } from "@/src/models/loginModel";
import { IDatabaseAccountDocument } from "@/src/types/loginTypes";
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);
const account = await Account.findOne({ _id: accountId });
if (account) {
account.Nonce = 0;
account.save();
}
2023-06-01 17:08:05 -07:00
res.writeHead(200, {
"Content-Type": "text/html",
"Content-Length": 1
2023-06-01 17:08:05 -07:00
});
res.end("1");
2023-06-01 17:08:05 -07:00
};
2023-06-02 00:20:49 -03:00
export { logoutController };