Compare commits

...

4 Commits

Author SHA1 Message Date
dvelo
4150d86ec7
fix: POST when unlinking is unnecessary 2025-01-18 09:10:17 -06:00
dvelo
67bdca8516 fix: POST when unlinking is unnecessary 2025-01-18 09:05:22 -06:00
dvelo
9afc39f4d6
fix: unlinking doesn't work 2025-01-18 08:53:39 -06:00
dvelo
ceedade382 fix: unlinking doesn't work 2025-01-18 08:51:03 -06:00
2 changed files with 4 additions and 5 deletions

@ -290,7 +290,6 @@ export async function unlinkMCAccount(): Promise<boolean> {
const response = await fetch(
connector(`/account-linking/unlink-account`, { version: 0 }),
{
method: "POST",
headers: {
"Content-Type": "application/json",
},

@ -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, {