Fix lint errors

This commit is contained in:
Brandon Keepers 2016-10-14 07:58:34 -05:00
parent acbf2ce7ed
commit 75b6ec56ac
No known key found for this signature in database
GPG Key ID: F9533396D5FACBF6
1 changed files with 12 additions and 8 deletions

View File

@ -33,18 +33,18 @@ function listen(webhook) {
// Authenticate as an installation for the given account
function auth(account) {
const installation = installations[account];
const github = new GitHubApi();
let token = tokens[installation.id];
const token = tokens[installation.id];
let result;
if (!token || new Date(token.expires_at) < new Date()) {
return createToken(installation).then(token => {
// cache token
tokens[installation.id] = token
});
result = createToken(installation);
} else {
const github = new GitHubApi();
github.authenticate({type: 'token', token: token.token});
return Promise.resolve(github);
result = Promise.resolve(github);
}
return result;
}
function register(installation) {
@ -58,12 +58,16 @@ function unregister(installation) {
// https://developer.github.com/early-access/integrations/authentication/#as-an-installation
function createToken(installation) {
const github = new GitHubApi();
github.authenticate({type: 'integration', token: jwt()});
return github.integrations.createInstallationToken({
installation_id: installation.id
}).then(token => {
// cache token
tokens[installation.id] = token;
github.authenticate({type: 'token', token: token.token});
return github;
});
}