Improved team system
This commit is contained in:
@@ -1,12 +1,16 @@
|
||||
import { applyUsername } from "~/server/utils/auth";
|
||||
|
||||
export default defineEventHandler(async (event) => {
|
||||
const auth = await getAuth(event)
|
||||
const user = await getAuth(event)
|
||||
|
||||
if (!auth.minecraft.uuid) throw createError({ errorCode: 400, statusMessage: 'Geen Minecraft account is gekoppeld' })
|
||||
|
||||
const minecraftProfile = await $fetch(`https://sessionserver.mojang.com/session/minecraft/profile/${auth.minecraft.uuid}`)
|
||||
const minecraftProfile = await $fetch(`https://sessionserver.mojang.com/session/minecraft/profile/${user.minecraft.uuid}`)
|
||||
|
||||
const usersColl = db.collection('users')
|
||||
await usersColl.findOneAndUpdate({ 'minecraft.uuid': auth.minecraft.uuid }, { $set: { 'minecraft.username': minecraftProfile.name } })
|
||||
const newUser = await usersColl.findOneAndUpdate({ 'minecraft.uuid': auth.minecraft.uuid }, { $set: { 'minecraft.username': minecraftProfile.name, username: user.useMinecraftUsername ? minecraftProfile.name : user.discord.username } }, { returnDocument: 'after' })
|
||||
|
||||
applyUsername(newUser.value)
|
||||
|
||||
return { username: minecraftProfile.name }
|
||||
return newUser.value
|
||||
});
|
||||
|
Reference in New Issue
Block a user