Skip to content

Issue #5: Add JWT Token Expiry Handling & Refresh #5

@Nel-ctrl

Description

@Nel-ctrl

Type: Bug/UX
Priority: High

Description

Users receive a 7-day JWT token that is stored in localStorage. When the token expires, GraphQL requests fail silently with 401 errors, but the user is not redirected to login. This creates a confusing UX where the app appears broken.

Acceptance Criteria

  • Expired JWT is detected by Apollo Client error handler
  • User is automatically redirected to /login
  • Error message shown: "Session expired. Please log in again."
  • Optional: Implement refresh token rotation (15min token + refresh token)
  • localStorage is cleared on logout or token expiry

Tasks

  • Add error link to Apollo Client to catch 401 errors
  • Implement logout on unauthorized error
  • Clear AuthContext and localStorage on expiry
  • Redirect to /login
  • Show toast notification
  • (Optional) Implement refresh token endpoint in auth-service

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingenhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions