Skip to content

Commit a3f48e9

Browse files
waleedlatif1claude
andcommitted
fix(security): use session email directly instead of extra DB query
Addresses PR review feedback — align with the workspace invitation route pattern by using session.user.email instead of re-fetching from the database. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 6026598 commit a3f48e9

File tree

1 file changed

+2
-7
lines changed
  • apps/sim/app/api/organizations/[id]/invitations/[invitationId]

1 file changed

+2
-7
lines changed

apps/sim/app/api/organizations/[id]/invitations/[invitationId]/route.ts

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -62,13 +62,8 @@ export async function GET(
6262
}
6363

6464
// Verify caller is either an org member or the invitee
65-
const userData = await db
66-
.select({ email: user.email })
67-
.from(user)
68-
.where(eq(user.id, session.user.id))
69-
.then((rows) => rows[0])
70-
71-
const isInvitee = userData && userData.email.toLowerCase() === orgInvitation.email.toLowerCase()
65+
const isInvitee =
66+
session.user.email?.toLowerCase() === orgInvitation.email.toLowerCase()
7267

7368
if (!isInvitee) {
7469
const memberEntry = await db

0 commit comments

Comments
 (0)