From eed4f92927f4e8b9248e67fb750726dd1c327d37 Mon Sep 17 00:00:00 2001 From: Caleb Date: Sat, 19 Aug 2017 12:32:57 -0600 Subject: [PATCH] Fix denied login for users with many repos. `isCollaborator` was created in #491 to block login if a user did not have write (push) permissions to a repo, by going through the list of a users repos until it found the right one. It did not institute pagination, however, so if a user had enough repos that the one in question was on another page, the CMS would assume that they did not have permission and block the login. This commit fixes the problem by calling the API for the specific repo instead of getting the whole list. --- src/backends/github/API.js | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/src/backends/github/API.js b/src/backends/github/API.js index 68ed693fb168..e6b01ae0ee98 100644 --- a/src/backends/github/API.js +++ b/src/backends/github/API.js @@ -20,14 +20,8 @@ export default class API { } isCollaborator(user) { - return this.request('/user/repos').then((repos) => { - let contributor = false - for (const repo of repos) { - if (repo.full_name.toLowerCase() === this.repo.toLowerCase() && repo.permissions.push) contributor = true; - } - return contributor; - }).catch((error) => { - console.error("Problem with response of /user/repos from GitHub"); + return this.request(this.repoURL).then((repo) => (repo.permissions.push)).catch((error) => { + console.error("Problem fetching repo data from GitHub"); throw error; }) }