diff --git a/functions/v1/login/github/[code].js b/functions/v1/login/github/[code].js index c6c8d2f..ffbaec2 100644 --- a/functions/v1/login/github/[code].js +++ b/functions/v1/login/github/[code].js @@ -56,7 +56,7 @@ export async function onRequestGet(context) { const verificationResult = await app.authenticate() let memberEmail = verificationResult?.session?.memberEmail if (!memberEmail) { - const ghUserEmails = await gh.getUserEmails() + const ghUserEmails = await gh.getUserEmails(prisma) if (!ghUserEmails?.ok || ghUserEmails?.error?.message || !ghUserEmails?.content || !ghUserEmails.content?.length) { return Response.json({ ok: ghUserEmails.ok, error: ghUserEmails.error, result: `${ghUserEmails.status} ${ghUserEmails.statusText}` }) } @@ -147,7 +147,7 @@ export async function onRequestGet(context) { }) let installationId = githubApp?.installationId if (!installationId) { - const ghInstalls = await gh.getInstallations(response.session.orgId, response.session.memberEmail) + const ghInstalls = await gh.getInstallations(prisma, response.session.orgId, response.session.memberEmail) if (!ghInstalls?.ok || ghInstalls?.error?.message || !ghInstalls?.content?.installations || !ghInstalls.content?.installations?.length) { return Response.json({ ok: ghInstalls.ok, error: ghInstalls.error, result: `${ghInstalls.status} ${ghInstalls.statusText}` }) } diff --git a/src/utils.js b/src/utils.js index 58a534f..3493041 100644 --- a/src/utils.js +++ b/src/utils.js @@ -960,10 +960,6 @@ export class GitHub { } async getUserEmails(prisma, orgId, memberEmail) { // https://docs.github.com/en/rest/users/emails?apiVersion=2022-11-28#list-email-addresses-for-the-authenticated-user - const githubIntegration = await prisma.IntegrationConfig.findFirst({ where: { orgId, AND: { name: `github` } } }) - if (!!githubIntegration?.suspend) { - throw new Error('GitHub Integration is Disabled') - } const url = `${this.baseUrl}/user/emails` console.log(`github.getUserEmails() ${url}`) const data = await this.fetchJSON(url) @@ -985,10 +981,6 @@ export class GitHub { } async getUser(prisma, orgId, memberEmail) { // https://docs.github.com/en/rest/users/users?apiVersion=2022-11-28#get-the-authenticated-user - const githubIntegration = await prisma.IntegrationConfig.findFirst({ where: { orgId, AND: { name: `github` } } }) - if (!!githubIntegration?.suspend) { - throw new Error('GitHub Integration is Disabled') - } const url = `${this.baseUrl}/user` console.log(`github.getUser() ${url}`) const data = await this.fetchJSON(url)