-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix denied login for users with many repos. #543
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks Caleb! Just a code style request, other than that this looks good.
src/backends/github/API.js
Outdated
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) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nitpick - the extra parens can be dropped, and use multiple lines for clarity:
this.request(...)
.then(repo => repo.permissions.push)
.catch(error => {
...
});
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@erquhart this should be done.
`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.
eed4f92
to
6df35a2
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@@ -32,7 +32,7 @@ export default class GitHub { | |||
this.token = state.token; | |||
this.api = new API({ token: this.token, branch: this.branch, repo: this.repo, api_root: this.api_root }); | |||
return this.api.user().then(user => | |||
this.api.isCollaborator(user.login).then((isCollab) => { | |||
this.api.hasWriteAccess().then((isCollab) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should isCollab
be changed as well?
- Summary
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. Since there are only about 30 repos per page, this is a fairly significant bug.This commit fixes the problem by calling the API for the specific repo instead of getting the whole list.
- Test plan
Tested manually before and after:
Tested errors after:
- Description for the changelog
Fix denied login for users with many repos.