From c334c31dd2905a6c3c817e3122912717c22deba7 Mon Sep 17 00:00:00 2001 From: janderedev Date: Thu, 24 Mar 2022 16:15:22 +0100 Subject: [PATCH] fix /logout all not working --- bot/src/bot/commands/logout.ts | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/bot/src/bot/commands/logout.ts b/bot/src/bot/commands/logout.ts index 29dcb10..9b13490 100644 --- a/bot/src/bot/commands/logout.ts +++ b/bot/src/bot/commands/logout.ts @@ -20,19 +20,14 @@ export default { } if (code.toLowerCase() == 'all') { - const [ attempts, sessions ]: FindResult[] = await Promise.all([ - client.db.get('pending_logins').find({ user: message.author_id }), - client.db.get('sessions').find({ user: message.author_id }), + const [resA, resB] = await Promise.all([ + client.db.get('pending_logins').update({ user: message.author_id, invalid: false }, { $set: { invalid: true } }), + client.db.get('sessions').update({ user: message.author_id, invalid: false }, { $set: { invalid: true } }), ]); - if (attempts.length == 0 && sessions.length == 0) return message.reply('There are no sessions to invalidate.'); - - await Promise.all([ - client.db.get('pending_logins').update({ _id: { $in: attempts.map(a => a._id) } }, { $set: { invalid: true } }), - client.db.get('sessions').update({ _id: { $in: sessions.map(a => a._id) } }, { $set: { invalid: true } }), - ]); + if (resA.nModified == 0 && resB.nModified == 0) return message.reply('There are no sessions to invalidate.'); - message.reply(`Successfully invalidated ${attempts.length} codes and ${sessions.length} sessions.`); + message.reply(`Successfully invalidated ${resA.nModified} codes and ${resB.nModified} sessions.`); } else { const loginAttempt: FindOneResult = await client.db.get('pending_logins') .findOne({