Polarcraft/web/server/api/minecraft/removewhitelist.js

14 lines
551 B
JavaScript
Raw Normal View History

2023-04-28 16:56:36 +02:00
export default defineEventHandler(async (event) => {
const auth = await getAuth(event)
2023-05-09 16:01:19 +02:00
if (!auth.minecraft.uuid) throw createError({ errorCode: 400, statusMessage: 'Geen Minecraft account is gekoppeld' })
2023-04-28 16:56:36 +02:00
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' }
});