Disable additional affiliation constraint when used token is not from owner
This commit is contained in:
@@ -122,6 +122,7 @@
|
||||
authenticated = github.context.repo.owner
|
||||
}
|
||||
const user = _user || authenticated
|
||||
conf.authenticated = user
|
||||
info("GitHub account", user)
|
||||
if (q.repo)
|
||||
info("GitHub repository", `${user}/${q.repo}`)
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
import processes from "child_process"
|
||||
import util from "util"
|
||||
import url from "url"
|
||||
import OctokitRest from "@octokit/rest"
|
||||
|
||||
//Templates and plugins
|
||||
const Templates = {}
|
||||
@@ -26,6 +27,7 @@
|
||||
const logger = log ? console.debug : () => null
|
||||
logger("metrics/setup > setup")
|
||||
const conf = {
|
||||
authenticated:null,
|
||||
templates:{},
|
||||
queries:{},
|
||||
settings:{},
|
||||
@@ -100,7 +102,7 @@
|
||||
await fs.promises.rmdir(path.join(__templates, ".community"), {recursive:true})
|
||||
logger(`metrics/setup > loaded community template ${name}`)
|
||||
}
|
||||
catch (error) {
|
||||
catch (error) {
|
||||
logger(`metrics/setup > failed to load community template ${template}`)
|
||||
logger(error)
|
||||
}
|
||||
@@ -195,10 +197,21 @@
|
||||
//Load metadata (plugins)
|
||||
conf.metadata = await metadata({log})
|
||||
|
||||
//Store authenticated user
|
||||
if (conf.settings.token) {
|
||||
try {
|
||||
conf.authenticated = (await (new OctokitRest.Octokit({auth:conf.settings.token})).users.getAuthenticated()).data.login
|
||||
logger(`metrics/setup > setup > authenticated as ${conf.authenticated}`)
|
||||
}
|
||||
catch (error) {
|
||||
logger(`metrics/setup > setup > could not verify authentication : ${error}`)
|
||||
}
|
||||
}
|
||||
|
||||
//Set no token property
|
||||
Object.defineProperty(conf.settings, "notoken", {get() {
|
||||
return conf.settings.token === "NOT_NEEDED"
|
||||
}})
|
||||
return conf.settings.token === "NOT_NEEDED"
|
||||
}})
|
||||
|
||||
//Conf
|
||||
logger("metrics/setup > setup > success")
|
||||
|
||||
@@ -148,6 +148,7 @@
|
||||
}
|
||||
.activity .content {
|
||||
flex-grow: 1;
|
||||
max-width: 95%;
|
||||
}
|
||||
.activity quote {
|
||||
display: block;
|
||||
@@ -156,6 +157,7 @@
|
||||
border-radius: .25rem;
|
||||
border: 1px solid var(--color-border-secondary);
|
||||
color: var(--color-text-secondary);
|
||||
overflow-x: auto;
|
||||
}
|
||||
.activity quote p:first-child {
|
||||
margin-top: 0;
|
||||
@@ -163,6 +165,9 @@
|
||||
.activity quote p:last-child {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
.activity img {
|
||||
max-width: 100%;
|
||||
}
|
||||
|
||||
/* User */
|
||||
.user {
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
console.debug(`metrics/compute/${login}/base > started`)
|
||||
let {repositories, "repositories.forks":_forks, "repositories.affiliations":_affiliations} = imports.metadata.plugins.base.inputs({data, q, account:"bypass"}, {repositories:conf.settings.repositories ?? 100})
|
||||
const forks = _forks ? "" : ", isFork: false"
|
||||
const affiliations = _affiliations?.length ? `, ownerAffiliations: [${_affiliations.map(x => x.toLocaleUpperCase()).join(", ")}], affiliations: [${_affiliations.map(x => x.toLocaleUpperCase()).join(", ")}]` : ""
|
||||
const affiliations = _affiliations?.length ? `, ownerAffiliations: [${_affiliations.map(x => x.toLocaleUpperCase()).join(", ")}]${conf.authenticated === login ? `, affiliations: [${_affiliations.map(x => x.toLocaleUpperCase()).join(", ")}]` : ""}` : ""
|
||||
|
||||
//Skip initial data gathering if not needed
|
||||
if (conf.settings.notoken)
|
||||
|
||||
Reference in New Issue
Block a user