mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-04 09:26:14 +00:00
misc: added proper selection of existing github oauth
This commit is contained in:
@@ -209,12 +209,23 @@ export const integrationAuthServiceFactory = ({
|
|||||||
updateDoc.accessCiphertext = accessEncToken.ciphertext;
|
updateDoc.accessCiphertext = accessEncToken.ciphertext;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return integrationAuthDAL.transaction(async (tx) => {
|
return integrationAuthDAL.transaction(async (tx) => {
|
||||||
const doc = await integrationAuthDAL.findOne({ projectId, integration }, tx);
|
const integrationAuths = await integrationAuthDAL.find({ projectId, integration }, { tx });
|
||||||
if (!doc) {
|
let existingIntegrationAuth: TIntegrationAuths | undefined;
|
||||||
|
|
||||||
|
// we need to ensure that the integration auth that we use for Github is actually Oauth
|
||||||
|
if (integration === Integrations.GITHUB) {
|
||||||
|
existingIntegrationAuth = integrationAuths.find((integAuth) => !integAuth.metadata);
|
||||||
|
} else {
|
||||||
|
[existingIntegrationAuth] = integrationAuths;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!existingIntegrationAuth) {
|
||||||
return integrationAuthDAL.create(updateDoc, tx);
|
return integrationAuthDAL.create(updateDoc, tx);
|
||||||
}
|
}
|
||||||
return integrationAuthDAL.updateById(doc.id, updateDoc, tx);
|
|
||||||
|
return integrationAuthDAL.updateById(existingIntegrationAuth.id, updateDoc, tx);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user