Skip to content

Commit

Permalink
fix(api): use scalar field for rule ownership check
Browse files Browse the repository at this point in the history
Replace relation filter with scalar emailAccountId field in findUnique query for better security and performance.

- More efficient: avoids unnecessary join operation
- More explicit: directly filters on foreign key column
- Correct Prisma usage: findUnique should use scalar fields, not relation filters

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
  • Loading branch information
Eliezer Steinbock and Claude Sonnet 4.5 committed Jan 5, 2026
1 parent 49c30ca commit 41d5084
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion apps/web/app/api/user/rules/[id]/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ async function getRule({
emailAccountId: string;
}) {
const rule = await prisma.rule.findUnique({
where: { id: ruleId, emailAccount: { id: emailAccountId } },
where: { id: ruleId, emailAccountId },
include: {
actions: true,
},
Expand Down

0 comments on commit 41d5084

Please sign in to comment.