File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Load diff This file was deleted.
Original file line number Diff line number Diff 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 */
2523export 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
You can’t perform that action at this time.
0 commit comments