Phase 10, part 5: access enforced on every page, form and fragment

One table maps every address to an area (a module, Settings, anything
signed in, or public); each route is checked against it, and the app won't
start with a route missing from it. Changing needs edit on the module. For
members who may only view, forms that would change something are shown
disabled and htmx buttons hidden. The menu, the Overview, Search and the
SEO emails follow each person's modules; Settings is for admins.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-25 09:13:16 -07:00
co-authored by Claude Opus 5.5
parent 47a504b7b2
commit 2b9d04297f
13 changed files with 578 additions and 41 deletions
+8 -2
View File
@@ -22,7 +22,12 @@
{{end}}
</div>
{{if .Pending}}
{{if not .Modules}}
<section class="card empty"><p>You don't have any modules yet. An admin can give you some, under Settings → Users.</p></section>
{{end}}
{{if not .Admin}}
{{else if .Pending}}
<section class="card">
<h2>Setup</h2>
<ul class="steps">
@@ -45,7 +50,8 @@
</details>
{{end}}
{{if .ImportErr}}
{{if not .Admin}}
{{else if .ImportErr}}
<section class="card warn">
<h2>Import from the old app failed</h2>
<p>{{.ImportErr}}</p>
+6 -4
View File
@@ -35,9 +35,9 @@
</form>
<nav class="nav" aria-label="Main">
<a href="/" {{if eq .Nav "home"}}aria-current="page"{{end}}>{{template "icon" "overview"}}<span>Overview</span></a>
<a href="/market" {{if eq .Nav "inventory"}}aria-current="page"{{end}}>{{template "icon" "inventory"}}<span>Market</span></a>
{{if .Can "market"}}<a href="/market" {{if eq .Nav "inventory"}}aria-current="page"{{end}}>{{template "icon" "inventory"}}<span>Market</span></a>{{end}}
<div class="nav-label">Modules</div>
{{if .Modules}}<div class="nav-label">Modules</div>{{end}}
{{$nav := .Nav}}{{$inbox := .Inbox}}
{{range .Modules}}
{{if .Link}}
@@ -101,7 +101,7 @@
{{end}}
</nav>
<div class="sidebar-foot">
<a href="/settings/profile" {{if hasPrefix .Nav "settings"}}aria-current="page"{{end}}>{{template "icon" "settings"}}<span>Settings</span></a>
{{if .Can "admin"}}<a href="/settings/profile" {{if hasPrefix .Nav "settings"}}aria-current="page"{{end}}>{{template "icon" "settings"}}<span>Settings</span></a>{{end}}
{{with .Viewer}}{{with .User}}<div class="who"><a href="/settings/account" title="Your account">{{if .Name}}{{.Name}}{{else}}{{.Email}}{{end}}</a>
<form method="post" action="/signout"><button type="submit" class="secondary small">Sign out</button></form></div>{{end}}{{end}}
<p class="version">Supermarket {{.Version}}</p>
@@ -134,13 +134,14 @@
{{define "settings-start"}}
<div class="page-head">
<h1>Settings</h1>
<p class="lede">Your company, the accounts Supermarket posts with, the prospecting tools it reads, the AI it writes with, and your Federated Core.</p>
<p class="lede">{{if .Can "admin"}}Your company, the accounts Supermarket posts with, the prospecting tools it reads, the AI it writes with, and your Federated Core.{{else}}Your account.{{end}}</p>
</div>
<div class="settings">
<nav class="settings-nav" aria-label="Settings sections">
{{with .Viewer}}{{if .User}}<div class="nav-label">You</div>
<a href="/settings/account" {{if eq $.Nav "settings/account"}}aria-current="page"{{end}}>{{template "icon" "profile"}}Your account</a>
{{if .Member.Admin}}<a href="/settings/users" {{if eq $.Nav "settings/users"}}aria-current="page"{{end}}>{{template "icon" "prospects"}}Users</a>{{end}}{{end}}{{end}}
{{if $.Can "admin"}}
<div class="nav-label">Company</div>
<a href="/settings/profile" {{if eq .Nav "settings/profile"}}aria-current="page"{{end}}>{{template "icon" "profile"}}Profile</a>
<div class="nav-label">Connections</div>
@@ -155,6 +156,7 @@
<div class="nav-label">Data</div>
<a href="/settings/backups" {{if eq .Nav "settings/backups"}}aria-current="page"{{end}}>{{template "icon" "backups"}}Backups</a>
<a href="/settings/about" {{if eq .Nav "settings/about"}}aria-current="page"{{end}}>{{template "icon" "info"}}About</a>
{{end}}
</nav>
<div class="settings-body">
{{end}}
@@ -61,8 +61,12 @@
<label>Positions, more than <input name="min_positions" inputmode="decimal" value="{{$s.MinPositions}}" size="4"></label>
<label>On at least <input name="min_impressions" inputmode="numeric" value="{{$s.MinImpressions}}" size="6"> impressions</label>
</div>
{{if $.Viewer.User}}
<p class="help">The Monday report and the morning check (sent when something really moved, at most once a day) go to each person with SEO who asks for them, under Settings → Your account.</p>
{{else}}
<label class="check"><input type="checkbox" name="email_report" {{if $s.EmailReport}}checked{{end}}> Email me the Monday report (through the mailbox under <a href="/settings/email">Settings → Email</a>)</label>
<label class="check"><input type="checkbox" name="email_check" {{if $s.EmailCheck}}checked{{end}}> Email me the morning check when something really moved (at most once a day, when Search Console's data moves on)</label>
{{end}}
</section>
{{end}}