Skip to content

Commit

Permalink
Fix denied login for users with many repos.
Browse files Browse the repository at this point in the history
`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.
  • Loading branch information
tech4him1 authored Aug 19, 2017
1 parent de8db81 commit eed4f92
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions src/backends/github/API.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
})
}
Expand Down

0 comments on commit eed4f92

Please sign in to comment.