fix: add ownership check to resume delete mutation (CWE-862)

pull/759/head
Sebastion 3 weeks ago
parent 8ee2acb54a
commit 97f671f729
No known key found for this signature in database

@ -441,8 +441,19 @@ export const resumesResumeUserRouter = createProtectedRouter()
id: z.string(),
}),
async resolve({ ctx, input }) {
const userId = ctx.session.user.id;
const { id } = input;
const resume = await ctx.prisma.resumesResume.findUnique({
where: {
id,
},
});
if (resume?.userId !== userId) {
throw new Error('Unauthorized: you can only delete your own resumes');
}
return await ctx.prisma.resumesResume.delete({
where: {
id,

Loading…
Cancel
Save