Skip to content

Implement multi-tenant user ID support for encrypted records and update database schema#285

Open
jwaspin wants to merge 3 commits intorelease/2.6.0from
fix/multi-tenant-user-id-conflict
Open

Implement multi-tenant user ID support for encrypted records and update database schema#285
jwaspin wants to merge 3 commits intorelease/2.6.0from
fix/multi-tenant-user-id-conflict

Conversation

@jwaspin
Copy link
Copy Markdown
Contributor

@jwaspin jwaspin commented Feb 22, 2026

Summary

This pull request introduces significant improvements to the encrypted database's multi-user isolation and record management. The most important changes are the migration to composite primary keys for user-scoped stores, ensuring tenant isolation, and updates across the codebase to enforce user context during record deletion and persistence. Additionally, tests are added to verify correct user isolation behavior.

Database schema and migration improvements:

  • Migrated user-scoped stores (accounts, transactions, categories, statements, etc.) to use composite primary keys ([userId+id]), ensuring that records with the same ID for different users do not conflict and enforcing tenant isolation. Includes a migration strategy for legacy data. (src/crypto/database.js) [1] [2]
  • Updated data migration and user deletion utilities to operate on all user-scoped stores, ensuring proper cleanup and assignment of records per user. (src/crypto/database.js) [1] [2] [3]

Record deletion and persistence logic:

  • Modified record deletion functions (deleteEncryptedRecord, deleteUserEncryptedRecord) to require userId and use composite keys, preventing accidental cross-user deletions. (src/crypto/database.js) [1] [2]
  • Updated Redux action handlers and middleware to pass userId when deleting encrypted records, ensuring correct user context throughout the app. (src/store/accounts/actions.js, src/store/recurringTransactions/actions.js, src/store/recurringTransactionEvents/actions.js, src/store/statements/actions.js, src/store/encryptedMiddleware.js) [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11]

Middleware and queue enhancements:

  • Added getCurrentUserForMiddleware utility and updated write queue logic to include userId and dek for each operation, ensuring all persistence actions are scoped to the correct user. (src/store/encryptedMiddleware.js) [1] [2]

Testing for user isolation:

  • Added tests to verify that duplicate record IDs for different users do not conflict and that deleting a record only affects the current user's data. (src/__tests__/crypto/database.test.js)

Changes

Testing

  • pnpm lint
  • pnpm test

Checklist

  • Version updated appropriately in package.json
  • CHANGELOG updated
  • Tests updated/added if needed
  • No console warnings/errors introduced

Related Issues

  • Closes #

Manual QA

  • Navigate between Dashboard (/dashboard) and Accounts (/accounts)
  • Create an account via "Create New Account"
  • Verify Material-UI components render correctly
  • Confirm version display appears (vX.Y.Z) and update dialog dismisses

@cloudflare-workers-and-pages
Copy link
Copy Markdown

cloudflare-workers-and-pages bot commented Feb 23, 2026

Deploying beta-lucaledger with  Cloudflare Pages  Cloudflare Pages

Latest commit: 2a193dd
Status: ✅  Deploy successful!
Preview URL: https://da13fbe1.beta-lucaledger.pages.dev
Branch Preview URL: https://fix-multi-tenant-user-id-con.beta-lucaledger.pages.dev

View logs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant