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
|
authenticated = github.context.repo.owner
|
||||||
}
|
}
|
||||||
const user = _user || authenticated
|
const user = _user || authenticated
|
||||||
|
conf.authenticated = user
|
||||||
info("GitHub account", user)
|
info("GitHub account", user)
|
||||||
if (q.repo)
|
if (q.repo)
|
||||||
info("GitHub repository", `${user}/${q.repo}`)
|
info("GitHub repository", `${user}/${q.repo}`)
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
import processes from "child_process"
|
import processes from "child_process"
|
||||||
import util from "util"
|
import util from "util"
|
||||||
import url from "url"
|
import url from "url"
|
||||||
|
import OctokitRest from "@octokit/rest"
|
||||||
|
|
||||||
//Templates and plugins
|
//Templates and plugins
|
||||||
const Templates = {}
|
const Templates = {}
|
||||||
@@ -26,6 +27,7 @@
|
|||||||
const logger = log ? console.debug : () => null
|
const logger = log ? console.debug : () => null
|
||||||
logger("metrics/setup > setup")
|
logger("metrics/setup > setup")
|
||||||
const conf = {
|
const conf = {
|
||||||
|
authenticated:null,
|
||||||
templates:{},
|
templates:{},
|
||||||
queries:{},
|
queries:{},
|
||||||
settings:{},
|
settings:{},
|
||||||
@@ -195,10 +197,21 @@
|
|||||||
//Load metadata (plugins)
|
//Load metadata (plugins)
|
||||||
conf.metadata = await metadata({log})
|
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
|
//Set no token property
|
||||||
Object.defineProperty(conf.settings, "notoken", {get() {
|
Object.defineProperty(conf.settings, "notoken", {get() {
|
||||||
return conf.settings.token === "NOT_NEEDED"
|
return conf.settings.token === "NOT_NEEDED"
|
||||||
}})
|
}})
|
||||||
|
|
||||||
//Conf
|
//Conf
|
||||||
logger("metrics/setup > setup > success")
|
logger("metrics/setup > setup > success")
|
||||||
|
|||||||
@@ -148,6 +148,7 @@
|
|||||||
}
|
}
|
||||||
.activity .content {
|
.activity .content {
|
||||||
flex-grow: 1;
|
flex-grow: 1;
|
||||||
|
max-width: 95%;
|
||||||
}
|
}
|
||||||
.activity quote {
|
.activity quote {
|
||||||
display: block;
|
display: block;
|
||||||
@@ -156,6 +157,7 @@
|
|||||||
border-radius: .25rem;
|
border-radius: .25rem;
|
||||||
border: 1px solid var(--color-border-secondary);
|
border: 1px solid var(--color-border-secondary);
|
||||||
color: var(--color-text-secondary);
|
color: var(--color-text-secondary);
|
||||||
|
overflow-x: auto;
|
||||||
}
|
}
|
||||||
.activity quote p:first-child {
|
.activity quote p:first-child {
|
||||||
margin-top: 0;
|
margin-top: 0;
|
||||||
@@ -163,6 +165,9 @@
|
|||||||
.activity quote p:last-child {
|
.activity quote p:last-child {
|
||||||
margin-bottom: 0;
|
margin-bottom: 0;
|
||||||
}
|
}
|
||||||
|
.activity img {
|
||||||
|
max-width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
/* User */
|
/* User */
|
||||||
.user {
|
.user {
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
console.debug(`metrics/compute/${login}/base > started`)
|
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})
|
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 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
|
//Skip initial data gathering if not needed
|
||||||
if (conf.settings.notoken)
|
if (conf.settings.notoken)
|
||||||
|
|||||||
Reference in New Issue
Block a user