Polarcraft/web/server/api/minecraft/removewhitelist.js
2023-04-28 16:56:36 +02:00

14 lines
546 B
JavaScript

export default defineEventHandler(async (event) => {
const auth = await getAuth(event)
if (!auth.minecraft.uuid) throw createError({ errorCode: 400, statusMessage: 'No Minecraft account is linked' })
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' }
});