mirror of
https://github.com/ArthurDanjou/arthome.git
synced 2026-01-14 20:19:26 +01:00
21 lines
473 B
TypeScript
21 lines
473 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 setUserSession(event, {
|
|
id: user.id,
|
|
user: updatedUser,
|
|
})
|
|
|
|
return sendNoContent(event, 204)
|
|
})
|