@@ -105,7 +105,7 @@ export async function handleCreateCredentialFromDraft(params: {
105105 * the dead flag. Callers treat that timestamp as proof the reconnect landed.
106106 */
107107export async function handleReconnectCredential ( params : {
108- draft : { credentialId : string | null ; workspaceId : string ; displayName : string }
108+ draft : { credentialId : string | null }
109109 newAccountId : string
110110 workspaceId : string
111111 userId : string
@@ -115,7 +115,11 @@ export async function handleReconnectCredential(params: {
115115 if ( ! draft . credentialId ) return
116116
117117 const [ existingCredential ] = await db
118- . select ( { id : schema . credential . id , accountId : schema . credential . accountId } )
118+ . select ( {
119+ id : schema . credential . id ,
120+ accountId : schema . credential . accountId ,
121+ displayName : schema . credential . displayName ,
122+ } )
119123 . from ( schema . credential )
120124 . where ( eq ( schema . credential . id , draft . credentialId ) )
121125 . limit ( 1 )
@@ -125,6 +129,7 @@ export async function handleReconnectCredential(params: {
125129 }
126130
127131 const oldAccountId = existingCredential . accountId
132+ const displayName = existingCredential . displayName
128133 const accountChanged = oldAccountId !== newAccountId
129134
130135 if ( accountChanged ) {
@@ -171,10 +176,10 @@ export async function handleReconnectCredential(params: {
171176 action : AuditAction . CREDENTIAL_RECONNECTED ,
172177 resourceType : AuditResourceType . CREDENTIAL ,
173178 resourceId : draft . credentialId ,
174- resourceName : draft . displayName ,
179+ resourceName : displayName ,
175180 description : accountChanged
176- ? `Reconnected OAuth credential "${ draft . displayName } " to a new account`
177- : `Reconnected OAuth credential "${ draft . displayName } "` ,
181+ ? `Reconnected OAuth credential "${ displayName } " to a new account`
182+ : `Reconnected OAuth credential "${ displayName } "` ,
178183 metadata : { oldAccountId, newAccountId } ,
179184 } )
180185
0 commit comments