Skip to content

Commit

Permalink
fix: fix
Browse files Browse the repository at this point in the history
  • Loading branch information
qin-guan committed Sep 23, 2023
1 parent 8dfd5a9 commit 338f10d
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions server/api/user/[id].post.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export default defineProtectedEventHandler(async (event) => {

const { data } = result

const user = await event.context.database.update(users)
const updatedUsers = await event.context.database.update(users)
.set({
firebaseId: data.firebaseId,
})
Expand All @@ -26,7 +26,14 @@ export default defineProtectedEventHandler(async (event) => {
)
.returning()

return user
if (updatedUsers.length === 1) {
throw createError({
status: 500,
statusMessage: 'Internal server error',
})
}

return updatedUsers[0]
}, {
allowUnlinkedUser: true,
})

0 comments on commit 338f10d

Please # to comment.