Skip to content

Commit 7f2dd27

Browse files
Bill LeoutsakosBill Leoutsakos
authored andcommitted
revert(credentials): defer ambiguous draft handling
1 parent 23b30ac commit 7f2dd27

2 files changed

Lines changed: 2 additions & 126 deletions

File tree

apps/sim/lib/credentials/draft-processor.test.ts

Lines changed: 0 additions & 113 deletions
This file was deleted.

apps/sim/lib/credentials/draft-processor.ts

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,12 @@ interface ProcessCredentialDraftParams {
1818
/**
1919
* Looks up a pending credential draft for the given user/provider and processes it.
2020
* Creates a new credential or reconnects an existing one depending on the draft state.
21-
* If more than one workspace has a matching draft, fail closed: an uncorrelated
22-
* OAuth callback cannot safely determine which workspace initiated the connection.
2321
* Used by Better Auth's `account.create.after` hook and custom OAuth flows (Shopify, Trello).
2422
*/
2523
export async function processCredentialDraft(params: ProcessCredentialDraftParams): Promise<void> {
2624
const { userId, providerId, accountId } = params
2725

28-
const drafts = await db
26+
const [draft] = await db
2927
.select()
3028
.from(schema.pendingCredentialDraft)
3129
.where(
@@ -35,18 +33,9 @@ export async function processCredentialDraft(params: ProcessCredentialDraftParam
3533
sql`${schema.pendingCredentialDraft.expiresAt} > NOW()`
3634
)
3735
)
38-
.limit(2)
36+
.limit(1)
3937

40-
const [draft] = drafts
4138
if (!draft) return
42-
if (drafts.length > 1) {
43-
logger.error('Refusing to process ambiguous credential drafts', {
44-
userId,
45-
providerId,
46-
draftCount: drafts.length,
47-
})
48-
return
49-
}
5039

5140
const now = new Date()
5241

0 commit comments

Comments
 (0)