Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions src/controller/miscController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

import { Request, Response } from 'express';
import fs from 'fs';
import path from 'path';

import { logger } from '..';
import config from '../config';
Expand Down Expand Up @@ -160,10 +161,10 @@ export async function clearSessionData(req: Request, res: Response) {
delete clientsArray[req.params.session];
await req.client.logout();
}
const path = config.customUserDataDir + session;
const pathToken = __dirname + `../../../tokens/${session}.data.json`;
if (fs.existsSync(path)) {
await fs.promises.rm(path, {
const pathUserData = config.customUserDataDir + session;
const pathToken = path.resolve(process.cwd(), 'tokens', `${session}.data.json`);
if (fs.existsSync(pathUserData)) {
await fs.promises.rm(pathUserData, {
recursive: true,
});
}
Expand Down
3 changes: 2 additions & 1 deletion src/controller/sessionController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { Message, Whatsapp } from '@wppconnect-team/wppconnect';
import { Request, Response } from 'express';
import fs from 'fs';
import mime from 'mime-types';
import path from 'path';
import QRCode from 'qrcode';
import { Logger } from 'winston';

Expand Down Expand Up @@ -300,7 +301,7 @@ export async function logOutSession(req: Request, res: Response): Promise<any> {

setTimeout(async () => {
const pathUserData = config.customUserDataDir + req.session;
const pathTokens = __dirname + `../../../tokens/${req.session}.data.json`;
const pathTokens = path.resolve(process.cwd(), 'tokens', `${req.session}.data.json`);

if (fs.existsSync(pathUserData)) {
await fs.promises.rm(pathUserData, {
Expand Down