Awey
12/31/2021, 11:20 PMupdate
with prisma
prisma.post.update({
where: { id: postId },
data: { ...data }
})
How come they never check that the resource belongs to the person making the call to update?
Even if the route is protected wouldn't that allow anyone who is authenticated to update resources that don't belong to them?Awey
12/31/2021, 11:24 PMconst post = prisma.post.findUnique({
where: { id: postId }
})
if (post.authorId !== userId) throw Error() // userId being currently logged in user
prisma.post.update({
where: { id: postId },
data: { ...data }
})
Wouldn't this be the correct way to do it?Maciek K
12/31/2021, 11:33 PMAwey
12/31/2021, 11:34 PMAwey
12/31/2021, 11:35 PMMaciek K
12/31/2021, 11:46 PM.update
will probably allow you only one unique
argument. Can you check?
prisma.post.updateMany({
where: { id: postId, authorId: userId },
data: { ...data }
})
Maciek K
12/31/2021, 11:52 PMRobert Fish
01/01/2022, 1:18 AMAwey
01/01/2022, 1:53 AMAwey
01/01/2022, 1:54 AMwhere
and data
field so I don't think I can return the data I need from using updateMany
Awey
01/01/2022, 1:54 AMAwey
01/01/2022, 1:54 AM