forked from mirrors/probot
Fix lint errors
This commit is contained in:
parent
acbf2ce7ed
commit
75b6ec56ac
|
@ -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;
|
||||
});
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue