add organizer role and features
All checks were successful
Build Images and Deploy / Update-PROD-Stack (push) Successful in 29s

This commit is contained in:
2026-02-28 01:50:20 -05:00
parent e97bf95ca8
commit 83e552bd07
8 changed files with 173 additions and 40 deletions

View File

@@ -2,7 +2,7 @@
<div class="container">
<div style="display: flex; align-items: center; justify-content: space-between; margin-bottom: 1.5rem;">
<h1>Admin Dashboard</h1>
<h1><%= typeof isAdmin !== 'undefined' && isAdmin ? 'Admin' : 'Organizer' %> Dashboard</h1>
<a href="/admin/hunts/new" class="btn btn-primary">+ New Hunt</a>
</div>
@@ -25,6 +25,7 @@
<% }) %>
<% } %>
<% if (typeof isAdmin !== 'undefined' && isAdmin) { %>
<h2 style="margin-top: 2rem; margin-bottom: 1rem;">Password Reset</h2>
<div class="card">
<p style="color: var(--muted); font-size: 0.9rem; margin-bottom: 1rem;">Generate a one-time password reset link for a user. The link expires in 24 hours.</p>
@@ -34,7 +35,7 @@
<select name="username" class="form-control" required>
<option value="">Select user...</option>
<% if (typeof users !== 'undefined' && users) { users.forEach(u => { %>
<option value="<%= u.username %>"><%= u.username %><%= u.is_admin ? ' (admin)' : '' %></option>
<option value="<%= u.username %>"><%= u.username %><%= u.is_admin ? ' (admin)' : u.is_organizer ? ' (organizer)' : '' %></option>
<% }); } %>
</select>
</div>
@@ -52,6 +53,40 @@
</div>
<% } %>
</div>
<h2 style="margin-top: 2rem; margin-bottom: 1rem;">Manage Roles</h2>
<div class="card">
<p style="color: var(--muted); font-size: 0.9rem; margin-bottom: 1rem;">Grant or revoke the <strong>Organizer</strong> role. Organizers can create hunts and manage their own hunts only.</p>
<div class="table-wrapper">
<table>
<thead>
<tr><th>User</th><th>Role</th><th>Action</th></tr>
</thead>
<tbody>
<% if (typeof users !== 'undefined' && users) { users.filter(u => !u.is_admin).forEach(u => { %>
<tr>
<td><a href="/player/<%= u.username %>"><%= u.username %></a></td>
<td><%= u.is_organizer ? 'Organizer' : 'Player' %></td>
<td>
<% if (u.is_organizer) { %>
<form method="POST" action="/admin/users/<%= u.id %>/role" style="margin:0;">
<input type="hidden" name="role" value="player">
<button type="submit" class="btn btn-sm btn-danger" onclick="return confirm('Remove organizer role from <%= u.username %>?')">Remove Organizer</button>
</form>
<% } else { %>
<form method="POST" action="/admin/users/<%= u.id %>/role" style="margin:0;">
<input type="hidden" name="role" value="organizer">
<button type="submit" class="btn btn-sm btn-success">Make Organizer</button>
</form>
<% } %>
</td>
</tr>
<% }); } %>
</tbody>
</table>
</div>
</div>
<% } %>
</div>
<%- include('../partials/footer') %>