@@ -139,6 +139,7 @@ func linkByIncomingOAuthSpec(
139139 ctx context.Context ,
140140 deps * authflow.Dependencies ,
141141 flows authflow.Flows ,
142+ userID string ,
142143 request * CreateIdentityRequestOAuth ,
143144 identificationJSONPointer jsonpointer.T ,
144145) (conflicts []* AccountLinkingConflict , err error ) {
@@ -191,6 +192,12 @@ func linkByIncomingOAuthSpec(
191192
192193 for _ , iden := range idenConflicts {
193194 iden := iden
195+
196+ // Exclude identities that actually belong to this user.
197+ if iden .UserID == userID {
198+ continue
199+ }
200+
194201 // Exclude duplicates
195202 if _ , exist := conflictedIdentityIDs [iden .ID ]; exist {
196203 continue
@@ -227,6 +234,7 @@ func linkByIncomingLoginIDSpec(
227234 ctx context.Context ,
228235 deps * authflow.Dependencies ,
229236 flows authflow.Flows ,
237+ userID string ,
230238 request * CreateIdentityRequestLoginID ,
231239 identificationJSONPointer jsonpointer.T ,
232240) (conflicts []* AccountLinkingConflict , err error ) {
@@ -271,6 +279,12 @@ func linkByIncomingLoginIDSpec(
271279
272280 for _ , iden := range idenConflicts {
273281 iden := iden
282+
283+ // Exclude identities that actually belong to this user.
284+ if iden .UserID == userID {
285+ continue
286+ }
287+
274288 // Exclude duplicates
275289 if _ , exist := conflictedIdentityIDs [iden .ID ]; exist {
276290 continue
0 commit comments