Compare commits

..

No commits in common. "4150d86ec7c58dc340368b687e91b92f1216b0b2" and "0eef4ed4f68fe6eb9a88309bf066621241feb865" have entirely different histories.

2 changed files with 5 additions and 4 deletions

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

@ -46,13 +46,13 @@ export default async function handler(
const db = client.db(process.env.CUSTOM_MONGO_DB ?? "mhsf"); const db = client.db(process.env.CUSTOM_MONGO_DB ?? "mhsf");
const users = db.collection("claimed-users"); const users = db.collection("claimed-users");
if ((await users.find({ userId }).toArray()).length === 0) { const user = await (await clerkClient()).users.getUser(userId);
if (user.publicMetadata.player == undefined) {
res.status(400).send({ result: "Hasn't linked yet!" }); res.status(400).send({ result: "Hasn't linked yet!" });
return; return;
} }
await users.findOneAndDelete({ userId }); await users.findOneAndDelete({ player: user.publicMetadata.player });
const user = await (await clerkClient()).users.getUser(userId);
await ( await (
await clerkClient() await clerkClient()
).users.updateUserMetadata(userId, { ).users.updateUserMetadata(userId, {