From ceedade3823ee68340f0408ab1b18da654cf7765 Mon Sep 17 00:00:00 2001 From: dvelo <52332868+DeveloLongScript@users.noreply.github.com> Date: Sat, 18 Jan 2025 08:51:03 -0600 Subject: [PATCH] fix: unlinking doesn't work --- src/pages/api/v0/account-linking/unlink-account.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/pages/api/v0/account-linking/unlink-account.ts b/src/pages/api/v0/account-linking/unlink-account.ts index 12384c4..c7c808f 100644 --- a/src/pages/api/v0/account-linking/unlink-account.ts +++ b/src/pages/api/v0/account-linking/unlink-account.ts @@ -46,13 +46,13 @@ export default async function handler( const db = client.db(process.env.CUSTOM_MONGO_DB ?? "mhsf"); const users = db.collection("claimed-users"); - const user = await (await clerkClient()).users.getUser(userId); - - if (user.publicMetadata.player == undefined) { + if ((await users.find({ userId }).toArray()).length === 0) { res.status(400).send({ result: "Hasn't linked yet!" }); return; } - await users.findOneAndDelete({ player: user.publicMetadata.player }); + await users.findOneAndDelete({ userId }); + const user = await (await clerkClient()).users.getUser(userId); + await ( await clerkClient() ).users.updateUserMetadata(userId, {