feat: Added username configuration, closes #19
This commit is contained in:
parent
3c5e20e18e
commit
e68097d813
16
webv2/server/api/users/[id]/username.put.ts
Normal file
16
webv2/server/api/users/[id]/username.put.ts
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
export default defineEventHandler(async (event) => {
|
||||||
|
const { usernameType } = await readBody(event)
|
||||||
|
const userId: string = event.context.params ? event.context.params.id : '@me'
|
||||||
|
|
||||||
|
if (usernameType !== 'discord' && usernameType !== 'minecraft') {
|
||||||
|
throw createError({ statusCode: 400, statusMessage: 'UsernameType must be discord or minecraft' })
|
||||||
|
}
|
||||||
|
|
||||||
|
const user = await getUser(userId, event)
|
||||||
|
|
||||||
|
user.usernameType = usernameType
|
||||||
|
|
||||||
|
await applyUsername(user)
|
||||||
|
|
||||||
|
return user.username
|
||||||
|
})
|
Loading…
x
Reference in New Issue
Block a user