Improved team system

This commit is contained in:
2023-05-11 19:46:18 +02:00
parent cde8e6c827
commit 51705f8651
22 changed files with 811 additions and 32 deletions

View File

@@ -13,7 +13,7 @@ export default defineEventHandler(async (event) => {
client_secret: config.discordSecret,
code: code,
grant_type: 'authorization_code',
redirect_uri: 'http://localhost:3000/api/auth',
redirect_uri: config.redirectURI,
scope: 'identify',
}).toString(),
headers: {

View File

@@ -1,4 +1,5 @@
import { ObjectId } from "mongodb";
import { applyUsername } from "~/server/utils/auth";
export default defineEventHandler(async (event) => {
const { type } = await readBody(event)
@@ -8,7 +9,8 @@ export default defineEventHandler(async (event) => {
const username = type === 'discord' ? auth.discord.username : auth.minecraft.username
await usersColl.updateOne({ _id: new ObjectId(auth._id) }, { $set: { username: username, useMinecraftUsername: type === 'discord' ? false : true } })
const newUser = await usersColl.findOneAndUpdate({ _id: new ObjectId(auth._id) }, { $set: { username: username, useMinecraftUsername: type === 'discord' ? false : true } }, { returnDocument: 'after' })
await applyUsername(newUser.value)
return { username: username }
return newUser.value
});