mitlist/fe/src/stores
google-labs-jules[bot] 6e56e164df Fix: Prevent automatic logout when starting app offline
Problem:
The application would inadvertently log you out if it was started while offline.
This occurred because the `fetchCurrentUser` action in the `authStore` would attempt to fetch your profile, and if this network request failed (as it does when offline), the catch block would unconditionally call `clearTokens()`. This removed the authentication token, effectively logging you out and preventing access to any cached data or offline functionality.

Solution:
I modified the `fetchCurrentUser` action in `fe/src/stores/auth.ts`:
- The `catch` block now inspects the error.
- `clearTokens()` is only called if the error is a specific HTTP authentication error from the server (401 Unauthorized or 403 Forbidden) when online.
- For network errors (indicating offline status) or other non-auth HTTP errors, tokens are preserved. The user object (`user.value`) might remain null if no cached profile is available, but the authentication token itself is kept.

This change allows the application to remain in a logged-in state when started offline. The service worker can then serve cached API responses, and you can view previously accessed data. Navigation guards rely on `isAuthenticated` (which now remains true offline as long as a token exists), so you are not incorrectly redirected to the login page.
2025-06-07 20:30:52 +00:00
..
__tests__ feat: Implement traceable expense splitting and settlement activities 2025-05-22 07:05:31 +00:00
auth.ts Fix: Prevent automatic logout when starting app offline 2025-06-07 20:30:52 +00:00
groupStore.ts Remove deprecated task management files and enhance group management functionality 2025-06-07 18:05:08 +02:00
listDetailStore.ts Implement bulk status retrieval for lists and refine list status handling 2025-06-07 18:55:35 +02:00
notifications.ts migrate to vue+vueuse+valerieui bc quasar customisation is sad 2025-05-13 19:23:15 +02:00
offline.ts feat: Add comprehensive notes and tasks for project stabilization and enhancements 2025-05-24 21:36:57 +02:00