export default defineEventHandler(async (event) => {
  const auth = await getAuth(event)

  if (!auth.minecraft.uuid) throw createError({ errorCode: 400, statusMessage: 'Geen Minecraft account is gekoppeld' })
  
  const whitelistColl = db.collection('whitelist')
  await whitelistColl.deleteOne({ uuid: auth.minecraft.uuid })

  const usersColl = db.collection('users')
  await usersColl.findOneAndUpdate({ 'minecraft.uuid': auth.minecraft.uuid }, { $set: { 'minecraft.uuid': null, 'minecraft.username': null } })
  
  return { code: 'success' }
});
