Use case-insensitive role check (user.role | lower == 'admin') so the
password field shows correctly even if the role was stored with mixed
case (e.g. 'Admin' via the Streamlit interface).
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Password field in edit user modal is now hidden for managers.
Backend already blocks non-admins from updating users.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Adds a DELETE USER button to the edit user modal with a confirmation
dialog. Includes a self-deletion guard on both the frontend and backend.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Password complexity: enforce 12+ chars, uppercase, lowercase, number, and
special character on /setup-password and admin password-reset flow; show
requirements hint on login page
- Data retention: cleanup_old_logs(days=90) purges activity_log and
interactions rows older than 90 days; runs at every startup in lifespan
- PII hashing: add _hash_quote() SHA-256 helper (16-char prefix) for
correlation without storing raw customer text in audit records; activity_log
already stores no raw quotes — helper available for future log calls
- import hashlib added to main.py
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Rate limiting (slowapi):
- /login: 10 attempts/minute per IP
- /setup-password: 3 attempts/10min per IP
- /admin/export/users: 5 exports/hour
- /browse/export.csv: 10 exports/hour
- Uses X-Forwarded-For for HF Spaces proxy compatibility
- Logs failed login attempts with IP for forensics
Admin-only restrictions (close manager privilege escalation):
- /admin/users/update: managers can no longer reset passwords or modify users
(per requirement: managers can only ADD users, not edit them)
- /admin/export/users: only admins can exfiltrate user emails/login times
- Edit button hidden in admin UI for managers
Audit trail:
- Failed logins logged with IP
- All CSV exports logged (users + browse responses)
- Password change actions explicitly flagged in activity log
Input validation (Pydantic Field constraints):
- PredictRequest: quote 5000c, group 50c, service 200c
- CorrectionRequest: all fields capped (200c types, 5000c quote)
- BrowseEditRequest: response/solution 10000c, follow-up 2000…
Fix admin page encoding issues and use company logo as favicon
- Replace company logo as favicon (browser tab icon) using logo-transparent.png
- Fix admin tab title from corrupted 'Admin â€" Explorer' to 'Admin - Explorer'
- Fix Export CSV button: replace garbled char with proper down arrow (↓)
- Replace garbled trash emoji in corrections delete button with 'Delete' text
Cache-bust favicon version to v=3 to force browser refresh.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Fix critical Jinja2 syntax error in admin.html corrections delete
Smart/curly quotes (U+2018, U+2019) were accidentally introduced
during the role hierarchy refactor edit, breaking Jinja2 parsing
and causing Internal Server Error on /admin page load.
Replaced with proper ASCII single quotes.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Fix: Replace Jinja2 'in' operator with explicit or checks for template compatibility
Changed 'user.role in [list]' to 'user.role == 'admin' or user.role == 'manager''
to avoid potential Jinja2 compatibility issues.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Rework role hierarchy: admin/manager/staff with granular permissions
Role structure:
- Admin (3): Full access to all pages and operations
- Manager (2): Access all pages + admin panel, but can only add users (not delete)
- Staff (1): Access consultants/analytics/browse (read-only), can save corrections
Changes:
- Rename employee→manager, viewer→staff in role definitions
- Update PAGE_ACCESS to reflect new permissions
- Add admin-only authorization checks on all delete endpoints
- /admin/corrections/delete
- /browse/delete, /browse/edit
- /analytics/delete
- Update admin.html with new role select options (staff/manager/admin)
- Hide delete buttons from non-admin users in corrections table
- Allow managers to access admin navigation link in base.html and home.html
- Add .role-manager CSS styling (blue/purple)
- Update database default role from employee to staff
- Remove obsolete .role-employee CSS selector
Backward compatibility: Existing 'employee' and 'viewer' users need migration:
UPDATE users SET role = 'manager' WHERE role = 'employee';
…