Admin opens on the admin role, with the key only as a bootstrap

This commit is contained in:
gator 2026-09-07 12:39:57 +00:00
parent a2095eb806
commit af95cf1802

View file

@ -51,15 +51,14 @@
<script src="/assets/app.js"></script>
<script>
// Access is the admin ROLE on the signed-in session. The key remains only as
// a bootstrap for granting the very first admin, and is not needed after that.
var KEY = null;
try { KEY = localStorage.getItem("ptl_admin"); } catch (e) {}
navBar("admin");
function money(v) { return v == null ? "—" : "$" + Number(v).toFixed(2); }
function when(s) {
if (!s) return "";
var d = new Date(s);
return isNaN(d) ? s : d.toLocaleString();
}
// when() comes from app.js and carries the time.
function shotHtml(s) {
var over = s.words > 18;
@ -106,7 +105,7 @@ function projHtml(p) {
async function load() {
hideMsg("msg");
var r = await api("admin_overview", { admin_key: KEY });
var r = await api("admin_overview", KEY ? { admin_key: KEY } : {});
if (!r.ok) {
showMsg("msg", r.error || "Could not load.");
document.getElementById("gate").style.display = "";
@ -136,7 +135,8 @@ document.getElementById("go").onclick = function () {
load();
};
if (KEY) load();
// A signed-in admin never sees the key prompt.
if (Session.token() || KEY) load();
</script>
</body>
</html>