Skip to content

Commit

Permalink
Merge pull request #75 from chekjun/P2FancyTeacherModeFix
Browse files Browse the repository at this point in the history
P2 fancy teacher mode fix
  • Loading branch information
chekjun committed Jun 15, 2021
2 parents 76e8983 + 38ab4cd commit 23d4e37
Showing 1 changed file with 4 additions and 21 deletions.
25 changes: 4 additions & 21 deletions src/pages/githubAssessments/GitHubAssessmentWorkspace.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -265,27 +265,10 @@ const GitHubAssessmentWorkspace: React.FC<GitHubAssessmentWorkspaceProps> = 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;
})
.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 isTeacherModePromise = octokit.users.getAuthenticated().then((authenticatedUser: any) => {
const userLogin = authenticatedUser.data.login;
return userLogin === missionRepoData.repoOwner;
});

const promises = [missionDataPromise, isTeacherModePromise];

Expand Down

0 comments on commit 23d4e37

Please sign in to comment.