fix /logout all not working

This commit is contained in:
janderedev 2022-03-24 16:15:22 +01:00
parent bbfbf66cec
commit c334c31dd2
No known key found for this signature in database
GPG key ID: 5D5E18ACB990F57A

View file

@ -20,19 +20,14 @@ export default {
}
if (code.toLowerCase() == 'all') {
const [ attempts, sessions ]: FindResult<any>[] = 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<PendingLogin> = await client.db.get('pending_logins')
.findOne({