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