in htdocs/js/boxer.js [712:780]
async function prime() {
let canvas = document.getElementById('main');
let formdata = {};
let matches = location.search.match(/[^?=&]+=[^&]+/g);
if (matches) {
matches.reduce((acc, value) => {
let a = value.split("=", 2);
formdata[a[0]] = decodeURIComponent(a[1]);
}, 10
);
}
// Fetch prefs, see if we're authed
let login = await GET("api/preferences.json");
login_cached = login;
// If OAuth call, bypass the prefs check
if (formdata.action == "oauth") {
oauth = await POST("api/oauth.json", formdata);
if (oauth.okay) {
location.href = "/boxer/";
return
} else {
alert("Something went wrong... :(");
}
}
// Otherwise, if not logged in yet, go to OAuth
else if (!login.credentials.uid) {
let oauth_url = encodeURIComponent(`https://${hostname}/boxer/?action=oauth&state=` + state);
location.href = "https://oauth.apache.org/auth?redirect_uri=" + oauth_url + "&state=" + state;
return
}
// Hide admin nav items if not admin
if (!login.credentials.admin) {
const adminlinks = document.getElementsByClassName("adminonly");
for (const navitem of adminlinks) {
navitem.style.display = "none";
}
}
if (!formdata.action || formdata.action == 'preferences') {
// Not authed via GitHub yet
if (!login.github || !login.github.login) {
setup_step_one_github_auth(canvas, login);
return
}
// Authed via GitHub but not in Apache Org yet
if (login.credentials && !login.credentials.github_org_member) {
setup_step_two_github_org(canvas, login);
return
}
// MFA not enabled yet
if (!login.github.mfa) {
setup_step_three_mfa(canvas, login);
return
}
show_page_profile(canvas, login);
return
} else if (formdata.action == 'search') {
search_page(canvas, formdata.query||"");
} else if (formdata.action == 'newrepo') {
new_repo_prompt(canvas, login);
}
}