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