My Current Schema:
Code snippet
model Answer {
id String @id @default(uuid())
content String
codeSnippet String?
authorId String // Foreign key to User model
questionId String
createdAt DateTime @default(now())
}
My Current Server Action:
// app/actions.ts
export async function deleteAnswer(answerId: string) {
// Problem: This doesn't check WHO is making the request
await prisma.answer.delete({
where: { id: answerId }
});
revalidatePath('/question/[id]');
}
What I need:
How do I conditionally render the Edit/Delete buttons in the UI only for the owner?
How do I secure the Server Action so a malicious user can't trigger it via the console using someone else's answerId?
Isuru Sandeepa
Question Author