Skip to content

Fix: resolve authentication state pollution and subscription leaks - #132

Open
addiinnocent wants to merge 11 commits into
mainfrom
fix/profiles-unsubscribe
Open

Fix: resolve authentication state pollution and subscription leaks#132
addiinnocent wants to merge 11 commits into
mainfrom
fix/profiles-unsubscribe

Conversation

@addiinnocent

Copy link
Copy Markdown
Collaborator

Summary

  • Fixed reactive isAuthenticated computed property that wasn't tracking login state
  • Corrected Gun.js subscription cleanup using .off() instead of callback functions
  • Resolved profile data leakage when logging out and back in with different accounts
  • Added proper subscription management to prevent stacking on multiple logins
  • Removed hardcoded test emails and fixed logout button functionality

Technical

  • Store Gun references (userRef, profilesRef) instead of unsubscribe functions
  • Use Gun.js native .off() method for proper unsubscribe
  • Guard watch callback to prevent writing null values to Gun during logout
  • Added 500ms sync delay between register and login for credential persistence
  • Clear profiles array on login to prevent data mixing between accounts

Testing

  • Logout button now works correctly and redirects to login
  • Logging out and back in no longer shows previous account's profiles
  • Multiple consecutive logins don't stack subscriptions
  • Registration email stored in sessionStorage instead of hardcoded
  • Console logs show complete logout flow for debugging

Breaking Changes

None

Related Issues

Fixes logout functionality and authentication state pollution issues

addiinnocent and others added 11 commits July 15, 2025 15:00
- Updated .claude/settings and .gitignore
- Modified sphere InfoView and server index.html
- Added server application files and configuration
- Added compiled assets from build
- Fix isAuthenticated reactive computation to properly track login state
- Implement proper Gun.js subscription cleanup with .off() instead of callbacks
- Store Gun references (userRef, profilesRef) instead of trying to store unsubscribe functions
- Fix logout to properly unsubscribe from user and profiles before clearing state
- Guard against writing null values to Gun.js during logout
- Add 500ms sync delay between register and login to ensure credentials are written
- Remove hardcoded test emails from PasskeyView and RegisterView
- Store registration email in sessionStorage to pass to PasskeyView
- Fix missing useUser() import in SettingsView
- Add console logging for logout flow debugging

This fixes issues where:
- Logging out and back in would show profiles from previous account
- Logout button wouldn't work due to incorrect unsubscribe handling
- Multiple logins without logout would stack subscriptions
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.

2 participants