Public: anyone can read this; the crew can change it.

Access 3b, web pages: the remaining admin gates (a local user?.isAdmin, isAdmin !== true || agent) ask adminPage beside them #18413

opened this

Merged 1h 6m ago, live in production

mason/forge:mason/18401-access-3b-web-pages-the-remaining-admin → main 0 commits fork

  • Merged. mason/18401-access-3b-web-pages-the-remaining-admin was merged into main as b9d6e88.

Review

Sign in to review this change.
2 files changed +8 −1
src/web/pages/everyday.ts +1 −1
@@ -56,7 +56,7 @@ export function everydayPage(ctx: Ctx): Response {
5656 const user = ctx.auth.user;
5757 if (!user) return signInFirst(ctx);
5858 // Nothing to ask: not an admin, has one already, or is one.
59 if (!user.isAdmin || user.kind !== "user" || everydayOf(ctx.app.db, user) !== undefined || adminOf(ctx.app.db, user) !== undefined) return redirect("/settings");
59 if (!adminPage(ctx, "everyday", user.isAdmin) || user.kind !== "user" || everydayOf(ctx.app.db, user) !== undefined || adminOf(ctx.app.db, user) !== undefined) return redirect("/settings");
6060 notePhase(ctx.request, "session", takeSessionTime(ctx.request));
6161 return timePhase(ctx.request, "render", () => page({
6262 ctx,
test/web-pages-may.test.ts +7
@@ -119,3 +119,10 @@ test("a render helper inside a gated page does not ask again: backups' domains c
119119 expect(card).toContain("if (!ctx.auth.user) return null;");
120120 expect(card).not.toContain("signedInPage");
121121 });
122
123 test("the everyday step's admin gate asks beside it, and billing's render helpers do not ask twice", async () => {
124 const src = (f: string) => readFile(join(import.meta.dir, "../src/web/pages", f), "utf8");
125 expect(await src("everyday.ts")).toContain(`if (!adminPage(ctx, "everyday", user.isAdmin) ||`);
126 const billing = await src("billing.ts");
127 expect(billing.slice(billing.indexOf("function soldSection"), billing.indexOf("function soldSection") + 200)).not.toContain("adminPage");
128 });

Search
↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs