Skip to content

Bug: Missing 401 Unauthorized handling leaves user trapped when session expires #11

@windoze95

Description

@windoze95

Problem

In lib/services/api_service.dart (around line ~35), the Dio interceptor checks for errors and simply passes them on:

        onError: (error, handler) {
          handler.next(error);
        },

If the session token expires, or the backend clears the in-memory session (which happens on every backend restart), API calls start returning 401 Unauthorized.

There is no central logic to clear the getSessionToken in StorageService and redirect the user back to the profile picker. As a result, the user receives mysterious Failed to load errors and cannot switch profiles or log in again unless they clear app data.

Suggested Fix

Update the Dio onError interceptor to detect 401 responses. If detected, call a callback to clear the token and force navigation to the login/profile selection route (e.g. using a global NavigatorState key or Riverpod provider).

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions