diff --git a/functions/index.js b/functions/index.js index 30cf5c654..a05be6a60 100644 --- a/functions/index.js +++ b/functions/index.js @@ -867,6 +867,23 @@ exports.verifyUser = functions.https.onRequest(async (request, response) => { .then((res) => res.json()) .then(async (res2) => { let did = res2.id; + + if ( + (await db.collection("users").where("discordId", "==", did).get()) + .docs.length > 0 + ) { + response + .status(200) + .send({ + data: { + status: -1, + message: + "This Discord account is already paired to a different Monkeytype account", + }, + }); + return; + } + await db.collection("users").doc(request.uid).update({ discordId: did, }); diff --git a/src/js/script.js b/src/js/script.js index 533cb919b..01c9b5363 100644 --- a/src/js/script.js +++ b/src/js/script.js @@ -5655,6 +5655,7 @@ let mappedRoutes = { "/settings": "pageSettings", "/about": "pageAbout", "/account": "pageAccount", + "/verify": "pageTest", }; function handleInitialPageClasses(el) {