2023-06-06 10:37:30 +02:00
|
|
|
export default defineEventHandler(async (event) => {
|
|
|
|
const userId: string = event.context.params ? event.context.params.id : '@me'
|
|
|
|
|
|
|
|
const user = await getUser(userId, event)
|
|
|
|
|
|
|
|
if (user.$isEmpty('minecraft') || !user.minecraft) {
|
|
|
|
throw createError({ statusCode: 400, statusMessage: 'Minecraft has not been linked' })
|
|
|
|
}
|
|
|
|
|
|
|
|
try {
|
|
|
|
await WhitelistModel.deleteOne({ uuid: user.minecraft.uuid })
|
|
|
|
user.minecraft = undefined
|
|
|
|
|
2023-06-06 13:49:27 +02:00
|
|
|
await applyUsername(user)
|
2023-06-06 10:37:30 +02:00
|
|
|
} catch (e) {
|
|
|
|
console.error('Failed to update documents', e)
|
|
|
|
|
|
|
|
throw createError('Failed to update documents')
|
|
|
|
}
|
|
|
|
|
|
|
|
return ''
|
|
|
|
})
|