pedal/views/admin.ejs
2026-01-03 16:17:54 -05:00

66 lines
1.7 KiB
Plaintext

<%- include('partials/header', { title }) %>
<h1 class="title">Admin</h1>
<% if (pendingUsers.length === 0) { %>
<p class="has-text-grey">No pending accounts.</p>
<% } else { %>
<h2 class="title is-4">Pending approvals</h2>
<table class="table is-fullwidth is-striped">
<thead>
<tr>
<th>Username</th>
<th>Requested</th>
<th></th>
</tr>
</thead>
<tbody>
<% pendingUsers.forEach((user) => { %>
<tr>
<td><%= user.username %></td>
<td><%= new Date(user.created_at).toLocaleDateString() %></td>
<td>
<form method="post" action="/admin/users/<%= user.id %>/approve">
<button class="button is-small is-success" type="submit">Approve</button>
</form>
</td>
</tr>
<% }) %>
</tbody>
</table>
<% } %>
<h2 class="title is-4 mt-5">User accounts</h2>
<table class="table is-fullwidth is-striped">
<thead>
<tr>
<th>Username</th>
<th>Status</th>
<th>Reset password</th>
</tr>
</thead>
<tbody>
<% users.forEach((user) => { %>
<tr>
<td><%= user.username %></td>
<td>
<%= user.is_admin ? 'Admin' : 'User' %>
<span class="has-text-grey">· <%= user.is_approved ? 'Approved' : 'Pending' %></span>
</td>
<td>
<form method="post" action="/admin/users/<%= user.id %>/reset-password" class="field has-addons">
<div class="control">
<input class="input is-small" type="password" name="password" placeholder="New password" required />
</div>
<div class="control">
<button class="button is-small is-warning" type="submit">Reset</button>
</div>
</form>
</td>
</tr>
<% }) %>
</tbody>
</table>
<%- include('partials/footer') %>