Some checks are pending
Build Docker image / docker (push) Waiting to run
Build / build (18) (push) Successful in 1m15s
Build / build (20) (push) Successful in 1m5s
Build / build (22) (push) Successful in 1m12s
Build / build (18) (pull_request) Successful in 1m19s
Build / build (22) (pull_request) Successful in 52s
Build / build (20) (pull_request) Successful in 1m15s
Reducing 3-4 MongoDB operations to only 1.
25 lines
600 B
TypeScript
25 lines
600 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.end();
|
|
};
|