Skip to content

Commit

Permalink
fix: GH login
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisdlangton committed Oct 28, 2024
1 parent 9b39545 commit f7bacf8
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 10 deletions.
4 changes: 2 additions & 2 deletions functions/v1/login/github/[code].js
Original file line number Diff line number Diff line change
Expand Up @@ -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}` })
}
Expand Down Expand Up @@ -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}` })
}
Expand Down
8 changes: 0 additions & 8 deletions src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down

0 comments on commit f7bacf8

Please sign in to comment.