🛡️ Warracker is an open source, self-hostable warranty tracker to monitor expirations, store receipts, files. You own the data, your rules!
Guard saveThemePreference call on pages without the theme module
Omega (QA)ceb775cf1d18
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 364c8cf..0587035 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -13,6 +13,8 @@- _Files: `frontend/js/components/tagManager.js`_### Fixed+- **`saveThemePreference is not defined` ReferenceError on status.html fixed:** the prefs loader in `script.js` called the global `saveThemePreference()`, which is only defined by the `js/lib/theme.js` ES module loaded on index.html. Every status-page load logged a console error and aborted the prefs sync, so saved filters, expiring-soon days, and date format were never written to localStorage there. The call is now guarded with a `typeof` check. Found by the daily QA sweep.+ - _Files: `frontend/script.js`- **Login/registration/password-change 500 on passwords over 72 bytes fixed:** bcrypt rejects passwords longer than 72 bytes with `ValueError`, which escaped as HTTP 500 on `/api/auth/login` (and latently on register and the password reset/change endpoints for strong long passwords). All four endpoints now check the byte length up front via a new `is_password_too_long()` helper and return HTTP 400. Found by the daily QA sweep.- _Files: `backend/auth_routes.py`, `backend/auth_utils.py`- **Insecure direct file access via `/api/files/` fixed (reported by Malik Abdullah):** the legacy `/api/files/<path>` route served any uploaded document to any logged-in user with no ownership check and no regard for the admin's document-sharing (`global_view_enabled`) setting — while `/api/secure-file/` on the same files correctly returned 403. Verified live: with sharing disabled, a second account downloaded another user's invoice via `/api/files/` (200) while `/api/secure-file/` returned 403. Both routes now share a single `_check_file_authorization()` helper (owner, admin, or global-view setting), so they can no longer drift apart; `/api/files/` also gained the path-traversal guard. With sharing enabled (the default, intentional for family/team instances) cross-user access still works consistently on both routes. Credit: reported via responsible disclosure by [humidnhefty](https://github.com/humidnhefty) (Malik Abdullah, Lupine Security).diff --git a/frontend/script.js b/frontend/script.jsindex 76e328a..ed4f6a4 100644--- a/frontend/script.js+++ b/frontend/script.js@@ -6785,8 +6785,12 @@ async function loadAndApplyUserPreferences(isAuthenticated) { // Added isAuthent// Apply theme from API and sync to localStorageif (apiPrefs.theme) {const isDark = apiPrefs.theme === 'dark';- // Apply without triggering API save to avoid loops- await saveThemePreference(isDark, false);+ // Apply without triggering API save to avoid loops.+ // theme.js (which defines saveThemePreference) only loads on+ // index.html, so guard for other pages like status.html.+ if (typeof saveThemePreference === 'function') {+ await saveThemePreference(isDark, false);+ }console.log(`[Prefs Loader] Applied theme from API: ${apiPrefs.theme}`);}// Save filter preferences from API to localStorage