mirror of
https://github.com/ArthurDanjou/arthome.git
synced 2026-01-25 09:00:29 +01:00
Working
This commit is contained in:
17
server/api/users/me.put.ts
Normal file
17
server/api/users/me.put.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
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)
|
||||
})
|
||||
Reference in New Issue
Block a user