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
Merged 1h 6m ago, live in production
mason/forge:mason/18401-access-3b-web-pages-the-remaining-admin → main 0 commits fork
2 files
changed +8
−1
src/web/pages/everyday.ts +1 −1
| @@ -56,7 +56,7 @@ export function everydayPage(ctx: Ctx): Response { | ||
| 56 | 56 | const user = ctx.auth.user; |
| 57 | 57 | if (!user) return signInFirst(ctx); |
| 58 | 58 | // 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"); | |
| 60 | 60 | notePhase(ctx.request, "session", takeSessionTime(ctx.request)); |
| 61 | 61 | return timePhase(ctx.request, "render", () => page({ |
| 62 | 62 | 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 | ||
| 119 | 119 | expect(card).toContain("if (!ctx.auth.user) return null;"); |
| 120 | 120 | expect(card).not.toContain("signedInPage"); |
| 121 | 121 | }); |
| 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 | }); |
new above
offline