Skip to content

Commit

Permalink
fix: Improovment delete data on logout session
Browse files Browse the repository at this point in the history
  • Loading branch information
icleitoncosta committed Jun 1, 2023
1 parent d925dfb commit 3ba21a2
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/controller/sessionController.ts
Expand Up @@ -263,6 +263,7 @@ export async function closeSession(req: Request, res: Response) {
export async function logOutSession(req: Request, res: Response) {
/**
* #swagger.tags = ["Auth"]
* #swagger.description = 'This route logout and delete session data'
#swagger.autoBody=false
#swagger.security = [{
"bearerAuth": []
Expand All @@ -274,6 +275,14 @@ export async function logOutSession(req: Request, res: Response) {
try {
const session = req.session;
await req.client.logout();
//await req.client.close();
delete clientsArray[req.session];
await fs.promises.rm(config.customUserDataDir + req.session, {
recursive: true,
});
await fs.promises.rm(
__dirname + `../../../tokens/${req.session}.data.json`
);

req.io.emit('whatsapp-status', false);
callWebHook(req.client, req, 'logoutsession', {
Expand Down

0 comments on commit 3ba21a2

Please sign in to comment.