mirror of
https://github.com/ArthurDanjou/arthome.git
synced 2026-01-14 12:14:33 +01:00
18 lines
443 B
TypeScript
18 lines
443 B
TypeScript
import { useValidatedBody } from 'h3-zod'
|
|
import { UpdateUserSchema } from '~~/types/types'
|
|
|
|
export default defineEventHandler(async (event) => {
|
|
const { user } = await requireUserSession(event)
|
|
const body = await useValidatedBody(event, UpdateUserSchema)
|
|
|
|
const updatedUser = {
|
|
...user,
|
|
...body,
|
|
}
|
|
|
|
await updateUser(user.id, updatedUser)
|
|
await replaceUserSession(event, updatedUser)
|
|
|
|
return sendNoContent(event, 204)
|
|
})
|