Prevent unauthorized CMS access () and enable use of GitHub Enterprise ()

* Prevent unauthorized CMS access and enable use of GitHub Enterprise
This commit is contained in:
tortilaman
2017-08-01 20:28:03 -07:00
committed by Benaiah Mischenko
parent b294110db7
commit 6805a6936d
6 changed files with 39 additions and 7 deletions

@ -19,6 +19,19 @@ export default class API {
return this.request("/user");
}
isCollaborator(user) {
return this.request('/user/repos').then((repos) => {
let contributor = false
for (const repo of repos) {
if (repo.full_name === this.repo && repo.permissions.push) contributor = true;
}
return contributor;
}).catch((error) => {
console.error("Problem with response of /user/repos from GitHub");
throw error;
})
}
requestHeaders(headers = {}) {
const baseHeader = {
"Content-Type": "application/json",
@ -241,7 +254,6 @@ export default class API {
persistFiles(entry, mediaFiles, options) {
const uploadPromises = [];
const files = mediaFiles.concat(entry);
files.forEach((file) => {
if (file.uploaded) { return; }