Skip to content

Remove createDefaultUser() Mock Function That Generates Fake Timestamp-Based User IDs #168

@portableDD

Description

@portableDD

Description

createDefaultUser() in user-context.tsx generates user IDs in the format "user_" + Date.now(). These are timestamp-based strings, not UUIDs. Once the frontend starts making real API calls, any endpoint that uses this ID (profile fetching, progress tracking, rewards, etc.) will fail because the backend expects and stores only proper UUIDs (e.g. 550e8400-e29b-41d4-a716-446655440000). This will cause silent failures that are hard to trace during integration.

// user-context.tsx — fake ID generation
const defaultUser: UserProfile = {
  id: "user_" + Date.now(), // not a UUID, will never match a real DB record
  fullName: name,
  email: email,
  role: "Student",
  createdAt: new Date(),
};

Proposed Actions

  • Remove the createDefaultUser() function from user-context.tsx entirely — it only exists to support the mock auth system
  • Set the initial user state to null instead of calling createDefaultUser()
  • Once auth is wired to the real API (as part of API integration work), the user object will be populated from the JWT token payload or /users/profile API response — it will always carry a real UUID from the backend
  • Update any UI that currently assumes user is non-null to handle the null case gracefully (show loading state or redirect to login)

Expected Outcome

  • No fake user IDs are generated or stored anywhere in the frontend
  • The user state starts as null and is only populated by real API responses
  • No UUID mismatch errors occur when API integration begins

Complexity

Trivial

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions