From 5d6c8f64a9ce77193ad5dbe4fdaa917588f60cb2 Mon Sep 17 00:00:00 2001 From: Skyler Grey Date: Fri, 30 Dec 2022 00:05:14 +0000 Subject: [PATCH] Fix the majority of verification race conditions Data races can probably still occur in the following cases: - If Discord is still adding the role when we fetch the user for the second time - If we don't all verify, for example if someone does a kick and someone else does a verify These are substantially less likely than the common case, which has happened several times now This was ported over from https://github.com/TransPlace-Devs/theo/pull/5 --- src/verification/managers/verifyUser.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/verification/managers/verifyUser.js b/src/verification/managers/verifyUser.js index 12ad802..51479a0 100644 --- a/src/verification/managers/verifyUser.js +++ b/src/verification/managers/verifyUser.js @@ -42,6 +42,11 @@ async function verifyUser(ticket, verifier, resolve, reject) { return; } + if (applicant.roles.cache.has(config.roles.verified)) { + await reject('User has already been verified'); + return; + } + // verify user await verify(applicant);