feat(admin): rebuild admin panel as out-of-band login with backups

- Separate admin login (ADMIN_USERNAME/ADMIN_PASSWORD) with its own JWT,
  no longer a seeded user account; lockout after 5 failed attempts
- Admin panel tabs: Users, Notifications, Backups, Reset
- Ntfy settings moved from .env/compose into admin_settings (token encrypted)
- Scheduled and on-demand mariadb-dump backups to NFS volume, with
  restore (entries only or all) and retention pruning
- Reset all entries, guarded by an automatic safety backup
- Remove user impersonation and the admin link in the user nav
- Login page falls back to admin login; nginx sends Cache-Control: no-cache

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
derekcandClaude Opus 5.5 committed 2026-11-23 00:24:19 -08:00
1 parent c54d2b251f
commit 6272322f31
28 files changed
+1523 -461

No files matched your search

+22 -50
View File
@@ -11,72 +11,44 @@
<nav>
<div class="nav-left">
<a href="/index.html" class="nav-brand">🥃 Bourbonacci</a>
<div class="nav-links" id="nav-links"></div>
<span class="nav-brand">🥃 Bourbonacci — Admin</span>
</div>
<div class="nav-user">
<button onclick="Admin.signOut()" class="btn btn-sm btn-ghost">Sign out</button>
</div>
<div id="nav-user"></div>
</nav>
<main>
<h1 class="page-title">Admin — User Management</h1>
<div id="msg"></div>
<div class="section-header">
<h2>All Users</h2>
<button class="btn btn-ghost btn-sm" onclick="loadUsers()">Refresh</button>
<div class="tabs">
<div class="tab" data-tab="users" onclick="Admin.showTab('users')">Users</div>
<div class="tab" data-tab="notifications" onclick="Admin.showTab('notifications')">Notifications</div>
<div class="tab" data-tab="backups" onclick="Admin.showTab('backups')">Backups</div>
<div class="tab" data-tab="reset" onclick="Admin.showTab('reset')">Reset</div>
</div>
<div class="table-wrap">
<table>
<thead>
<tr>
<th>Display Name</th>
<th>Email</th>
<th>Role</th>
<th>Status</th>
<th>Joined</th>
<th>Actions</th>
</tr>
</thead>
<tbody id="users-body">
<tr class="empty-row"><td colspan="6">Loading…</td></tr>
</tbody>
</table>
</div>
<div id="tab-content"></div>
<!-- Reset password modal -->
<div id="reset-modal" class="modal-overlay" style="display:none">
<div class="modal-box">
<h2>Reset Password</h2>
<p style="margin-bottom:1rem;color:var(--cream-dim)">Setting new password for: <strong id="reset-username"></strong></p>
<div id="reset-msg"></div>
<div class="form-group" style="margin-bottom:1rem">
<label>New Password</label>
<input type="password" id="reset-password" placeholder="Min 8 characters" />
</div>
<div style="display:flex;gap:0.5rem;justify-content:flex-end">
<button class="btn btn-ghost" onclick="hideResetModal()">Cancel</button>
<button class="btn btn-primary" onclick="submitReset()">Set Password</button>
</div>
</div>
</div>
<!-- Delete confirmation modal -->
<!-- Delete user confirmation modal -->
<div id="delete-modal" class="modal-overlay" style="display:none">
<div class="modal-box">
<h2>Delete User</h2>
<p style="margin-bottom:1.5rem;color:var(--cream-dim)">Delete <strong id="delete-username"></strong>? This will permanently remove their account and all associated data.</p>
<p style="margin-bottom:1rem;color:var(--cream-dim)">
This permanently deletes <strong id="delete-email"></strong>'s account and every entry they own.
This cannot be undone. Type the email address to confirm.
</p>
<div id="delete-msg"></div>
<div class="form-group">
<input type="text" id="delete-confirm" autocomplete="off" oninput="Admin.onDeleteConfirmInput()" />
</div>
<div style="display:flex;gap:0.5rem;justify-content:flex-end">
<button class="btn btn-ghost" onclick="hideDeleteModal()">Cancel</button>
<button class="btn btn-danger" onclick="submitDelete()">Delete</button>
<button class="btn btn-ghost" onclick="Admin.hideDeleteModal()">Cancel</button>
<button class="btn btn-danger" id="delete-submit" disabled onclick="Admin.submitDelete()">Delete permanently</button>
</div>
</div>
</div>
</main>
<script src="/js/api.js"></script>
<script src="/js/auth.js"></script>
<script src="/js/admin.js"></script>
<script src="/js/admin.js?v=2"></script>
</body>
</html>