feat: add duplicate account import prevention #189

Merged
jose merged 10 commits from account-import-duplicate-prevention into master 2025-09-01 13:58:49 +00:00
Owner
  • Add duplicate check in ImportAccountView before account import
  • Add duplicate check in ImportDerivedAccountView for derived accounts
  • Add safety check in saveNewIdentity function to prevent duplicate saves
  • Implement user-friendly warning messages for duplicate attempts
  • Add comprehensive error handling to catch duplicate errors from saveNewIdentity
  • Create Playwright tests to verify duplicate prevention functionality
  • Add documentation for duplicate prevention implementation

The system now prevents users from importing the same account multiple times
by checking for existing DIDs both before import (pre-check) and during
save (post-check). Users receive clear warning messages instead of
technical errors when attempting to import duplicate accounts.

Files modified:

  • src/views/ImportAccountView.vue: Add duplicate check and error handling
  • src/views/ImportDerivedAccountView.vue: Add duplicate check for derived accounts
  • src/libs/util.ts: Add duplicate prevention in saveNewIdentity
  • test-playwright/duplicate-import-test.spec.ts: Add comprehensive tests
  • doc/duplicate-account-import-implementation.md: Add implementation docs

Resolves: Prevent duplicate account imports in IdentitySwitcherView

- Add duplicate check in ImportAccountView before account import - Add duplicate check in ImportDerivedAccountView for derived accounts - Add safety check in saveNewIdentity function to prevent duplicate saves - Implement user-friendly warning messages for duplicate attempts - Add comprehensive error handling to catch duplicate errors from saveNewIdentity - Create Playwright tests to verify duplicate prevention functionality - Add documentation for duplicate prevention implementation The system now prevents users from importing the same account multiple times by checking for existing DIDs both before import (pre-check) and during save (post-check). Users receive clear warning messages instead of technical errors when attempting to import duplicate accounts. Files modified: - src/views/ImportAccountView.vue: Add duplicate check and error handling - src/views/ImportDerivedAccountView.vue: Add duplicate check for derived accounts - src/libs/util.ts: Add duplicate prevention in saveNewIdentity - test-playwright/duplicate-import-test.spec.ts: Add comprehensive tests - doc/duplicate-account-import-implementation.md: Add implementation docs Resolves: Prevent duplicate account imports in IdentitySwitcherView
jose added 2 commits 2025-08-28 08:59:35 +00:00
- Add duplicate check in ImportAccountView before account import
- Add duplicate check in ImportDerivedAccountView for derived accounts
- Add safety check in saveNewIdentity function to prevent duplicate saves
- Implement user-friendly warning messages for duplicate attempts
- Add comprehensive error handling to catch duplicate errors from saveNewIdentity
- Create Playwright tests to verify duplicate prevention functionality
- Add documentation for duplicate prevention implementation

The system now prevents users from importing the same account multiple times
by checking for existing DIDs both before import (pre-check) and during
save (post-check). Users receive clear warning messages instead of
technical errors when attempting to import duplicate accounts.

Files modified:
- src/views/ImportAccountView.vue: Add duplicate check and error handling
- src/views/ImportDerivedAccountView.vue: Add duplicate check for derived accounts
- src/libs/util.ts: Add duplicate prevention in saveNewIdentity
- test-playwright/duplicate-import-test.spec.ts: Add comprehensive tests
- doc/duplicate-account-import-implementation.md: Add implementation docs

Resolves: Prevent duplicate account imports in IdentitySwitcherView
- Add NOTIFY_DUPLICATE_ACCOUNT_IMPORT constant for import warnings
- Add NOTIFY_DUPLICATE_DERIVED_ACCOUNT constant for derived account warnings
- Update ImportAccountView.vue to use notification constants
- Update ImportDerivedAccountView.vue to use notification constants
- Update test file to use notification constants for assertions

Centralizes notification messages for better maintainability and consistency
with the existing notification system.

Files modified:
- src/constants/notifications.ts: Add new notification constants
- src/views/ImportAccountView.vue: Replace hardcoded messages with constants
- src/views/ImportDerivedAccountView.vue: Replace hardcoded messages with constants
- test-playwright/duplicate-import-test.spec.ts: Update test assertions
Author
Owner

@trentlarson @anomalist I wanted to hear your thoughts on the changes, specifically the redundancies with the duplication checks when deriving from an existing seed and when adding a new identity. Is it too much, or just right?

@trentlarson @anomalist I wanted to hear your thoughts on the changes, specifically the redundancies with the duplication checks when deriving from an existing seed and when adding a new identity. Is it too much, or just right?
jose added 1 commit 2025-08-28 10:33:41 +00:00
- Rename the test to run it earlier in the test suite
jose added 1 commit 2025-09-01 08:02:26 +00:00
- Replace constant usage with direct message string in ImportDerivedAccountView.vue
- Clean up import statement to remove unused import
- Remove unused constant from notifications.ts
jose added 1 commit 2025-09-01 10:05:28 +00:00
jose added 2 commits 2025-09-01 11:35:07 +00:00
- Generated document reads more like a log, and does not contribute to actual documentation of app
- Extract checkForDuplicateAccount methods from ImportAccountView and ImportDerivedAccountView
- Create unified utility function in src/libs/util.ts with TypeScript overloads
- Support both direct DID checking and mnemonic+derivation path checking
- Improve error handling with centralized logging via PlatformServiceFactory
- Add comprehensive JSDoc documentation for both function overloads
- Remove unused imports (deriveAddress, newIdentifier) from ImportAccountView

The utility function now provides a clean API:
- checkForDuplicateAccount(did) - for direct DID checking
- checkForDuplicateAccount(mnemonic, derivationPath) - for derivation + checking

Both components maintain identical functionality while using centralized logic.
jose added 1 commit 2025-09-01 12:02:26 +00:00
Replace dual string check with single unique identifier for more precise error handling
trentlarson added 1 commit 2025-09-01 12:41:36 +00:00
Owner

This all looks good. I just tweaked the error-message logic, so you can see that they are guaranteed to use the exact same message.

This all looks good. I just tweaked the error-message logic, so you can see that they are guaranteed to use the exact same message.
trentlarson added 1 commit 2025-09-01 12:58:52 +00:00
Owner

I just added another commit for a small change: I removed the "catch" from a couple places because all it did was log a message and then rethrow the error, while adding some logging. (This can get confusing, especially when the calling code knows how to handle the error, so I prefer just to let it propagate.)

I just added another commit for a small change: I removed the "catch" from a couple places because all it did was log a message and then rethrow the error, while adding some logging. (This can get confusing, especially when the calling code knows how to handle the error, so I prefer just to let it propagate.)
Author
Owner

Duly noted on those last changes.

Duly noted on those last changes.
jose merged commit 40c8189c51 into master 2025-09-01 13:58:49 +00:00
Sign in to join this conversation.
No Reviewers
No Label
2 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: trent_larson/crowd-funder-for-time-pwa#189