Fix stale token detection in TokenInjector so that expired IndexedDB tokens don't cause isAuthenticated to be incorrectly true, which prevents loginWithRedirect() from being called.
Problem
Auth0 SDK reads expired tokens from IndexedDB cache and temporarily evaluates isAuthenticated = true. When user taps "Login", handleAuthAction() sees isAuthenticated = true and calls navigate('/garage') instead of loginWithRedirect(). Tokens fail validation, isAuthenticated reverts to false, and user bounces back to homepage.
Changes
File: frontend/src/core/auth/Auth0Provider.tsx
After isAuthenticated becomes true, validate token is usable via getAccessTokenSilently({ cacheMode: 'off' })
If validation fails with login_required or consent_required, clear IndexedDB cache and reset Auth0 SDK state
Add clearAll() method to clear all cached auth tokens programmatically
Acceptance Criteria
Stale tokens are detected and cleared automatically
After clearing, isAuthenticated correctly reports false
User can then tap Login and reach Auth0 login page
Relates to #188
## Summary
Fix stale token detection in TokenInjector so that expired IndexedDB tokens don't cause `isAuthenticated` to be incorrectly `true`, which prevents `loginWithRedirect()` from being called.
## Problem
Auth0 SDK reads expired tokens from IndexedDB cache and temporarily evaluates `isAuthenticated = true`. When user taps "Login", `handleAuthAction()` sees `isAuthenticated = true` and calls `navigate('/garage')` instead of `loginWithRedirect()`. Tokens fail validation, `isAuthenticated` reverts to `false`, and user bounces back to homepage.
## Changes
- **File**: `frontend/src/core/auth/Auth0Provider.tsx`
- After `isAuthenticated` becomes `true`, validate token is usable via `getAccessTokenSilently({ cacheMode: 'off' })`
- If validation fails with `login_required` or `consent_required`, clear IndexedDB cache and reset Auth0 SDK state
- **File**: `frontend/src/core/utils/indexeddb-storage.ts`
- Add `clearAll()` method to clear all cached auth tokens programmatically
## Acceptance Criteria
- [ ] Stale tokens are detected and cleared automatically
- [ ] After clearing, `isAuthenticated` correctly reports `false`
- [ ] User can then tap Login and reach Auth0 login page
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Relates to #188
Summary
Fix stale token detection in TokenInjector so that expired IndexedDB tokens don't cause
isAuthenticatedto be incorrectlytrue, which preventsloginWithRedirect()from being called.Problem
Auth0 SDK reads expired tokens from IndexedDB cache and temporarily evaluates
isAuthenticated = true. When user taps "Login",handleAuthAction()seesisAuthenticated = trueand callsnavigate('/garage')instead ofloginWithRedirect(). Tokens fail validation,isAuthenticatedreverts tofalse, and user bounces back to homepage.Changes
frontend/src/core/auth/Auth0Provider.tsxisAuthenticatedbecomestrue, validate token is usable viagetAccessTokenSilently({ cacheMode: 'off' })login_requiredorconsent_required, clear IndexedDB cache and reset Auth0 SDK statefrontend/src/core/utils/indexeddb-storage.tsclearAll()method to clear all cached auth tokens programmaticallyAcceptance Criteria
isAuthenticatedcorrectly reportsfalse