admin: per-area permissions on every route
Give each user independent read, write and delete flags per area (invoices, bingo, users), so someone can e.g. review and remove bingo incidents without being able to add any. The request method and path decide the flag needed: GET is read except the new/duplicate forms, POST to .../delete is delete, any other POST is write. Unmapped admin paths are superuser-only, and a test enumerates every registered admin route so a new one cannot ship without a rule. Pages follow the same flags: nav and dashboard tiles show readable areas only, write forms and delete buttons are hidden, and the datacenter form is shown read-only. Assisted-by: Claude:opus-5
This commit is contained in:
parent
9bf40690e5
commit
8471570187
13 changed files with 214 additions and 27 deletions
|
|
@ -4,6 +4,7 @@
|
|||
</div>
|
||||
|
||||
<div class="dash">
|
||||
<% if @inv %>
|
||||
<section class="section dash-tile">
|
||||
<h2><a href="/admin/invoices">Invoices</a></h2>
|
||||
<div class="stats">
|
||||
|
|
@ -28,9 +29,11 @@
|
|||
</tbody>
|
||||
</table>
|
||||
<% end %>
|
||||
<p><a href="/admin/invoices/new">+ New invoice</a> · <a href="/admin/invoices">all invoices</a></p>
|
||||
<p><% if can?('invoices', 'write') %><a href="/admin/invoices/new">+ New invoice</a> · <% end %><a href="/admin/invoices">all invoices</a></p>
|
||||
</section>
|
||||
<% end %>
|
||||
|
||||
<% if @bingo %>
|
||||
<section class="section dash-tile">
|
||||
<h2><a href="/admin/bingo">Bingo</a></h2>
|
||||
<div class="stats">
|
||||
|
|
@ -46,4 +49,8 @@
|
|||
<% end %>
|
||||
<p><a href="/admin/bingo">manage</a><% if bingo_public_url %> · <a href="<%= bingo_public_url %>" target="_blank" rel="noopener">public card ↗</a><% end %></p>
|
||||
</section>
|
||||
<% end %>
|
||||
<% unless @inv || @bingo %>
|
||||
<section class="section"><p>No areas are assigned to your account yet. Ask an administrator for access.</p></section>
|
||||
<% end %>
|
||||
</div>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue