Skip to content

Commit

Permalink
Add basic feedback for unauthorized users.
Browse files Browse the repository at this point in the history
  • Loading branch information
tortilaman authored and erquhart committed Jul 21, 2017
1 parent 0e6e212 commit 8a49924
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions src/backends/github/implementation.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,20 @@ export default class GitHub {
authenticate(state) {
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 => (
return this.api.user().then(user =>
this.api.collaborator(user.login).then((status) => {
if (status === 404) {
if (status === 404 || status === 403) {
// Unauthorized user
throw new Error('You don\'t have publishing access.\nIf you think this is incorrrect, talk to the site administrator.');
alert("Sorry, but you don't appear to have publisher access. If you think this is incorrect, talk to the site administrator");
throw new Error('Talk to the site administrator to get publishing access.');
} else if (status === 204) {
// Authorized user
user.token = state.token;
return user;
}
// Authorized user
user.token = state.token;
return user;
throw new Error('No response from Github, that\'s odd.');
})
));
);
}

getToken() {
Expand Down

0 comments on commit 8a49924

Please sign in to comment.