Admin opens on the admin role, with the key only as a bootstrap
This commit is contained in:
parent
a2095eb806
commit
af95cf1802
1 changed files with 7 additions and 7 deletions
14
admin.html
14
admin.html
|
|
@ -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>
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue