Skip to content

Commit aeeead0

Browse files
committed
improvement(audit-log): add resourceName to credential set invitation accept
1 parent 767ba42 commit aeeead0

File tree

1 file changed

+2
-4
lines changed
  • apps/sim/app/api/credential-sets/invite/[token]

1 file changed

+2
-4
lines changed

apps/sim/app/api/credential-sets/invite/[token]/route.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ export async function POST(req: NextRequest, { params }: { params: Promise<{ tok
7979
status: credentialSetInvitation.status,
8080
expiresAt: credentialSetInvitation.expiresAt,
8181
invitedBy: credentialSetInvitation.invitedBy,
82+
credentialSetName: credentialSet.name,
8283
providerId: credentialSet.providerId,
8384
})
8485
.from(credentialSetInvitation)
@@ -126,7 +127,6 @@ export async function POST(req: NextRequest, { params }: { params: Promise<{ tok
126127
const now = new Date()
127128
const requestId = crypto.randomUUID().slice(0, 8)
128129

129-
// Use transaction to ensure membership + invitation update + webhook sync are atomic
130130
await db.transaction(async (tx) => {
131131
await tx.insert(credentialSetMember).values({
132132
id: crypto.randomUUID(),
@@ -148,8 +148,6 @@ export async function POST(req: NextRequest, { params }: { params: Promise<{ tok
148148
})
149149
.where(eq(credentialSetInvitation.id, invitation.id))
150150

151-
// Clean up all other pending invitations for the same credential set and email
152-
// This prevents duplicate invites from showing up after accepting one
153151
if (invitation.email) {
154152
await tx
155153
.update(credentialSetInvitation)
@@ -167,7 +165,6 @@ export async function POST(req: NextRequest, { params }: { params: Promise<{ tok
167165
)
168166
}
169167

170-
// Sync webhooks within the transaction
171168
const syncResult = await syncAllWebhooksForCredentialSet(
172169
invitation.credentialSetId,
173170
requestId,
@@ -192,6 +189,7 @@ export async function POST(req: NextRequest, { params }: { params: Promise<{ tok
192189
action: AuditAction.CREDENTIAL_SET_INVITATION_ACCEPTED,
193190
resourceType: AuditResourceType.CREDENTIAL_SET,
194191
resourceId: invitation.credentialSetId,
192+
resourceName: invitation.credentialSetName,
195193
description: `Accepted credential set invitation`,
196194
metadata: { invitationId: invitation.id },
197195
request: req,

0 commit comments

Comments
 (0)