fix: Auto add user to new team
This commit is contained in:
parent
9510e8a407
commit
034e203c1e
@ -1,5 +1,3 @@
|
||||
export default defineEventHandler((event) => {
|
||||
return {
|
||||
hello: 'world'
|
||||
}
|
||||
const userId: string = event.context.params ? event.context.params.id : '@me'
|
||||
})
|
||||
|
@ -1,6 +1,8 @@
|
||||
export default defineEventHandler(async (event) => {
|
||||
const { name, color } = await readBody(event)
|
||||
|
||||
const user = await getUser('@me', event)
|
||||
|
||||
const team = new TeamModel({
|
||||
name,
|
||||
color
|
||||
@ -8,5 +10,9 @@ export default defineEventHandler(async (event) => {
|
||||
|
||||
await team.save()
|
||||
|
||||
user.teamId = team._id
|
||||
|
||||
await user.save()
|
||||
|
||||
return team
|
||||
})
|
||||
|
@ -3,6 +3,7 @@ import { Schema, Types, model } from 'mongoose'
|
||||
const userSchema = new Schema({
|
||||
username: { type: String, required: false },
|
||||
usernameType: { type: String, required: true, default: 'discord' },
|
||||
teamId: { type: Types.ObjectId, ref: 'Team', required: false },
|
||||
discord: {
|
||||
id: { type: String, required: true, unique: true },
|
||||
username: { type: String, required: true }
|
||||
|
Loading…
Reference in New Issue
Block a user