Skip to content

Add proper user authentication to prevent data loss #10

@natcrypto

Description

@natcrypto

Problem

User identity is currently stored in localStorage (watchlist_user_id). This is fragile because:

  • Browser can clear localStorage automatically (storage pressure, privacy settings)
  • Users lose all their preferences if the key is lost
  • No way to access data from another device
  • Data becomes orphaned in the database with no way to recover

Current Flow

  1. First visit → create anonymous user → store UUID in localStorage
  2. Return visit → read UUID from localStorage → load user data
  3. localStorage cleared → data loss (new user created, old data orphaned)

Proposed Solution

Add proper authentication with multiple options:

Option 1: Email-based auth (Recommended)

  • Email + password registration
  • "Magic link" passwordless login option
  • Can migrate existing anonymous users by adding email to their account

Option 2: OAuth providers

  • Google / GitHub / Apple sign-in
  • Simpler UX but requires OAuth setup

Option 3: Device fingerprinting + email backup

  • Keep anonymous users but prompt for email as backup
  • Use email to recover if localStorage is lost

Implementation Notes

  • Use existing auth service at auth.adaptiveedge.uk if possible
  • Add migration path for existing anonymous users
  • Consider adding "Link your account" prompt after onboarding

Acceptance Criteria

  • Users can create account with email/password
  • Users can log in from any device
  • Existing anonymous users can link their data to an account
  • Session persists across browser restarts
  • Data is never lost due to localStorage clearing

This issue was created after a user lost all their preference data due to localStorage being cleared

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions