add multiple user and multiple language and fix cve
Security (CVE / Path Traversal)
deleteAssetFileAsync: Added apath.resolve()check againstDATA_DIRto prevent path traversal vulnerabilities./api/delete-file: Implemented the same protection; now returns a403 Forbiddenstatus code if the resolved path falls outside ofDATA_DIR.
Internationalization (i18n)
public/i18n/translations.js: Created a complete EN/IT translation module exposingwindow.i18nandwindow.t().- HTML Integration: Included the script in
index.htmlandlogin.htmlensuring it loads beforeconfig.js. - DOM Elements: Added
data-i18nanddata-i18n-placeholderattributes to key elements. - UI Updates: Added a "Language" tab in the settings menu with ๐ฌ๐ง English / ๐ฎ๐น Italiano toggle buttons.
- Styling: Added dedicated CSS rules for language selectors (
.lang-btn,.language-options).
Multi-user Support
/api/users: Endpoint added to fetch the user list (public, unauthenticated)./api/whoami: Endpoint added to return the current session user (authenticated)./verify-pin: Refactored to handle both single-user and multi-user modes (requiring username + PIN)./pin-length: Updated to returnmultiUser: truewhen active.- Login Flow: Completely rewrote
login.htmlto support a new multi-step flow: User Selection โ PIN Input โ Back Button. - Styling: Added custom CSS for
.user-btn,.user-list, and.back-btn. - Routing: Updated
publicPathsto allow access to/api/usersand/i18n/. - UI Updates: The logged-in user's badge is now displayed in the footer when multi-user mode is active.
Bug Fixes
- Search Reset: Fixed an issue where search queries were cleared;
loadAssets()now caches the search term before fetching and reapplies it afterward. - CSV Export Quantity: Added the missing
Quantitycolumn to both CSV generators (full and simple exports).
High-level PR Summary
This PR introduces multi-user authentication support with username selection and individual PIN verification, adds internationalization (i18n) with English and Italian translations, and fixes a path traversal security vulnerability (CVE) in file deletion endpoints. The changes include a new translation module with data-i18n attributes throughout the UI, a completely rewritten multi-step login flow that handles both single-user and multi-user modes, security enhancements using path.resolve() checks to prevent directory traversal attacks, and several bug fixes including missing Quantity column in CSV exports and search query persistence issues.
โฑ๏ธ Estimated Review Time: 30-90 minutes
๐ก Review Order Suggestion
| Order | File Path |
|---|---|
| 1 | server.js |
| 2 | public/i18n/translations.js |
| 3 | public/login.html |
| 4 | public/index.html |
| 5 | public/config.js |
| 6 | public/script.js |
| 7 | public/managers/settings.js |
| 8 | public/styles.css |
| 9 | package-lock.json |
| 10 | .replit |
โ ๏ธ Inconsistent Changes Detected
| File Path | Warning |
|---|---|
.replit |
Adding Replit-specific deployment configuration appears unrelated to the main PR objectives of multi-user support, i18n, and security fixes. This is infrastructure/deployment configuration that doesn't align with the stated feature additions. |
Summary by CodeRabbit
-
New Features
- Added internationalization support with English and Italian language options
- Introduced multi-user PIN authentication with user selection on login
- Added language selector in the settings interface
- Added user identification display showing logged-in user information
- Added Quantity column to CSV export functionality
-
Bug Fixes
- Search queries are now preserved when refreshing the asset list
- Enhanced security for file deletion operations
Walkthrough
This PR implements internationalization (English/Italian), multi-user PIN authentication, dashboard language switching, server-side user verification with IP lockout, path traversal protection for file deletion, and includes CSS styling, CSV export improvements, search persistence, and Replit configuration.
Changes
Multi-user authentication and internationalization infrastructure
| Layer / File(s) | Summary |
|---|---|
i18n translation engine and DOM integration public/i18n/translations.js, public/config.js |
Introduces TRANSLATIONS catalog for English and Italian, detects active language from localStorage or browser, exposes window.i18n API with t(), setLanguage(), getLanguage(), applyTranslations(), and wires DOM translation on DOMContentLoaded using data-i18n attributes. |
Login page multi-user and single-user flows public/login.html |
Refactors login to detect single vs. multi-user mode via /pin-length endpoint, renders conditional UI for user selection or direct PIN entry, implements buildPinInputs helper for digit input management, verifies via verify-pin with {username, pin} or {pin}, handles lockout/redirect messages with i18n labels. |
Server multi-user authentication endpoints and middleware server.js |
Parses DUMBASSETS_USERS into USERS array, adds /api/users and /api/whoami endpoints, refactors authMiddleware to handle multi-user sessions, extends pin-length/verify-pin to validate {username, pin} with IP-based brute-force lockout (429), and preserves single-user behavior when multi-user is disabled. |
Dashboard UI integration, styling, and hardening
| Layer / File(s) | Summary |
|---|---|
Dashboard language support and settings tab public/index.html |
Loads translations.js, applies i18n to sidebar search, "Add Asset" button, and Settings modal tabs, introduces Language/Lingua tab with language buttons, and internationalizes Save/Cancel/Test action buttons. |
User badge and language sync public/index.html (script section) |
Adds hidden user badge element, wires language button clicks to setLanguage(), syncs active button with current language, listens for languageChanged events, and fetches /api/whoami to display logged-in username. |
Login and dashboard UI styling public/styles.css |
Adds CSS for language selector buttons (.language-options, .lang-btn), multi-user user list (.user-list, .user-btn), and back button (.back-btn) with hover/active state styling. |
File deletion security and minor features server.js (path checks), public/managers/settings.js, public/script.js |
Hardens asset file deletion and /api/delete-file with path traversal boundary checks. Extends CSV exports to include Quantity field with 1 as default. Updates loadAssets() to preserve active search query on re-render. |
Replit environment configuration .replit |
Defines Replit environment with Node.js modules, expertMode agent settings, Nix stable-25_05 channel, server startup workflow (port 5000), port mappings, and VM deployment run command. |
๐๐ Multi-users now log in with their own PINs,
While languages dance between English and Italian spins,
Path traversal blocked with security gains,
Dashboard glows with i18n's refrains,
CSV counts quantities as the flow begins. ๐ฏ
๐ฏ 3 (Moderate) | โฑ๏ธ ~25 minutes
๐ฅ Pre-merge checks | โ 3 | โ 2
โ Failed checks (1 warning, 1 inconclusive)
| Check name | Status | Explanation | Resolution |
|---|---|---|---|
| Docstring Coverage | โ ๏ธ Warning | Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. | Write docstrings for the functions missing them to satisfy the coverage threshold. |
| Title check | โ Inconclusive | The PR title mentions the main features added (multiple users, multiple languages) but is vague about the CVE fix and lacks specificity about what changes were made. | Consider being more specific, such as: 'Add multi-user and i18n support with path traversal security fix' to better convey the scope and main objectives. |
โ Passed checks (3 passed)
| Check name | Status | Explanation |
|---|---|---|
| Description Check | โ Passed | Check skipped - CodeRabbitโs high-level summary is enabled. |
| Linked Issues check | โ Passed | Check skipped because no linked issues were found for this pull request. |
| Out of Scope Changes check | โ Passed | Check skipped because no linked issues were found for this pull request. |
โ๏ธ Tip: You can configure your own custom pre-merge checks in the settings.
โจ Finishing Touches
๐งช Generate unit tests (beta)
- [ ] Create PR with unit tests
[!WARNING] There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.
๐ง ESLint
If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.
ESLint skipped: no ESLint configuration detected in root package.json. To enable, add
eslintto devDependencies.
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Comment @coderabbitai help to get the list of available commands and usage tips.