Skip to content

Commit 741095b

Browse files
committed
fix(auth): end a swept session and its OAuth grants in one transaction
1 parent dbb3ff5 commit 741095b

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

‎apps/sim/lib/auth/auth.ts‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2086,8 +2086,11 @@ export async function enforceTwoFactorRequirement(
20862086
userId: session.user.id,
20872087
organizationId,
20882088
})
2089-
await db.delete(schema.session).where(eq(schema.session.id, session.session.id))
2090-
await revokeUserOAuthGrants(session.user.id)
2089+
/** Together, so a failed grant revocation cannot leave the grants behind a deleted session. */
2090+
await db.transaction(async (tx) => {
2091+
await tx.delete(schema.session).where(eq(schema.session.id, session.session.id))
2092+
await revokeUserOAuthGrants(session.user.id, tx)
2093+
})
20912094
return null
20922095
}
20932096

0 commit comments

Comments
 (0)