From eef9d1df193d85b51d57413da272ca545a69b0d3 Mon Sep 17 00:00:00 2001 From: ChengGeng97 <47176493+ChengGeng97@users.noreply.github.com> Date: Tue, 15 Jun 2021 14:22:57 +0800 Subject: [PATCH 1/2] fix: disable teacher mode if student is member of organization --- .../GitHubAssessmentWorkspace.tsx | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/src/pages/githubAssessments/GitHubAssessmentWorkspace.tsx b/src/pages/githubAssessments/GitHubAssessmentWorkspace.tsx index bd37590f9a..3e7b3d87e5 100644 --- a/src/pages/githubAssessments/GitHubAssessmentWorkspace.tsx +++ b/src/pages/githubAssessments/GitHubAssessmentWorkspace.tsx @@ -270,21 +270,6 @@ const GitHubAssessmentWorkspace: React.FC = prop .then((authenticatedUser: any) => { const userLogin = authenticatedUser.data.login; return userLogin === missionRepoData.repoOwner; - }) - .then(async (userOwnsRepo: boolean) => { - if (userOwnsRepo) return true; - - const userOrganisations = (await octokit.orgs.listForAuthenticatedUser()).data; - let userOrganisationOwnsRepo = false; - for (let i = 0; i < userOrganisations.length; i++) { - const org = userOrganisations[i]; - // User has admin access to an organization owning the repo - userOrganisationOwnsRepo = org.login === missionRepoData.repoOwner; - if (userOrganisationOwnsRepo) { - break; - } - } - return userOrganisationOwnsRepo; }); const promises = [missionDataPromise, isTeacherModePromise]; From 38ab4cd5ac4219760a8af4d39b6ea9083e243431 Mon Sep 17 00:00:00 2001 From: ChengGeng97 <47176493+ChengGeng97@users.noreply.github.com> Date: Tue, 15 Jun 2021 14:25:08 +0800 Subject: [PATCH 2/2] style: yarn run format --- .../githubAssessments/GitHubAssessmentWorkspace.tsx | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/pages/githubAssessments/GitHubAssessmentWorkspace.tsx b/src/pages/githubAssessments/GitHubAssessmentWorkspace.tsx index 3e7b3d87e5..9b284a260d 100644 --- a/src/pages/githubAssessments/GitHubAssessmentWorkspace.tsx +++ b/src/pages/githubAssessments/GitHubAssessmentWorkspace.tsx @@ -265,12 +265,10 @@ const GitHubAssessmentWorkspace: React.FC = prop if (octokit === undefined) return; const missionDataPromise = getMissionData(missionRepoData, octokit); - const isTeacherModePromise = octokit.users - .getAuthenticated() - .then((authenticatedUser: any) => { - const userLogin = authenticatedUser.data.login; - return userLogin === missionRepoData.repoOwner; - }); + const isTeacherModePromise = octokit.users.getAuthenticated().then((authenticatedUser: any) => { + const userLogin = authenticatedUser.data.login; + return userLogin === missionRepoData.repoOwner; + }); const promises = [missionDataPromise, isTeacherModePromise];