feat: role-aware presence bar, WebSocket logging fixes

- findAdminByKey returns role from admins.json (defaults to 'admin')
- JWT includes config-defined role instead of hardcoded 'admin'
- PresenceBar split into "who's here?" (page admins) and "connected"
  (bot/utility services with icon+color badges)
- Bot/utility roles appear in presence on all pages when connected
- usePresence hook uses refs to avoid WS reconnect on navigation
- WS auth log prints admin name instead of generic 'admin'
- WS connection log reads X-Forwarded-For for real client IP
- AuthContext stores adminRole from login response
- Uncomment admins.json Docker volume mount, add SELinux :z flags

Made-with: Cursor
This commit is contained in:
cottongin
2026-04-05 04:27:07 -04:00
parent 52e9a7af42
commit b2bb2989e9
9 changed files with 207 additions and 53 deletions

View File

@@ -1,4 +1,5 @@
[
{ "name": "Alice", "key": "change-me-alice-key" },
{ "name": "Bob", "key": "change-me-bob-key" }
{ "name": "Alice", "role": "admin", "key": "change-me-alice-key" },
{ "name": "Bob", "role": "bot", "key": "change-me-bob-key" },
{ "name": "Charlie", "role": "utility", "key": "change-me-charlie-key" }
]

View File

@@ -62,7 +62,7 @@ const admins = loadAdmins();
function findAdminByKey(key) {
const match = admins.find(a => a.key === key);
return match ? { name: match.name } : null;
return match ? { name: match.name, role: match.role || 'admin' } : null;
}
module.exports = { findAdminByKey, admins };