diff --git a/src/home/getters/get-github-access-token.ts b/src/home/getters/get-github-access-token.ts index c5303f8..4e19f00 100644 --- a/src/home/getters/get-github-access-token.ts +++ b/src/home/getters/get-github-access-token.ts @@ -1,31 +1,7 @@ declare const SUPABASE_STORAGE_KEY: string; // @DEV: passed in at build time check build/esbuild-build.ts -import { Octokit } from "@octokit/rest"; import { checkSupabaseSession } from "../rendering/render-github-login-button"; import { getLocalStore } from "./get-local-store"; -/** - * Checks if the logged-in user is part of Ubiquity's Org, and didn't grant the 'repo' scope - */ -export async function isOrgMemberWithoutScope() { - const octokit = new Octokit({ auth: await getGitHubAccessToken() }); - try { - await octokit.orgs.getMembershipForAuthenticatedUser({ - org: "ubiquity", - }); - } catch (e) { - if (e && typeof e === "object" && "status" in e && e.status === 404) { - return false; - } - throw e; - } - const { headers } = await octokit.request("HEAD /"); - if (headers) { - const scopes = headers["x-oauth-scopes"]?.split(", "); - return !scopes?.includes("repo"); - } - return false; -} - export async function getGitHubAccessToken(): Promise { // better to use official function, looking up localstorage has flaws const oauthToken = await checkSupabaseSession(); diff --git a/src/home/rendering/display-github-user-information.ts b/src/home/rendering/display-github-user-information.ts index 701a496..4e9437d 100644 --- a/src/home/rendering/display-github-user-information.ts +++ b/src/home/rendering/display-github-user-information.ts @@ -1,12 +1,10 @@ -import { isOrgMemberWithoutScope } from "../getters/get-github-access-token"; import { GitHubUser } from "../github-types"; import { toolbar } from "../ready-toolbar"; import { renderErrorInModal } from "./display-popup-modal"; -import { authenticationElement, getSupabase, renderAugmentAccessButton } from "./render-github-login-button"; +import { authenticationElement, getSupabase } from "./render-github-login-button"; export async function displayGitHubUserInformation(gitHubUser: GitHubUser) { const authenticatedDivElement = document.createElement("div"); - const containerDivElement = document.createElement("div"); authenticatedDivElement.id = "authenticated"; authenticatedDivElement.classList.add("user-container"); if (!toolbar) throw new Error("toolbar not found"); @@ -37,11 +35,6 @@ export async function displayGitHubUserInformation(gitHubUser: GitHubUser) { window.location.replace("/"); }); - if (await isOrgMemberWithoutScope()) { - const accessButton = renderAugmentAccessButton(); - containerDivElement.appendChild(accessButton); - } - authenticationElement.appendChild(authenticatedDivElement); toolbar.setAttribute("data-authenticated", "true"); toolbar.classList.add("ready");