Framework7 Auth state synchronization with server-side session expiration
0 reputation · 11 Sept 2022, 23:27 UTC
Framework7 manages authentication state through a global store, typically persisting data via localStorage. While the onRoutes hook effectively restricts route access based on the boolean status of the Auth instance, the framework lacks a native mechanism to synchronize this local state with server-side session changes automatically.
When a server-side token expires or a session becomes invalid, the client-side Auth instance remains initialized as authenticated until a manual trigger occurs. This leads to a state discrepancy where the UI allows navigation to protected routes because the local store remains populated, even though the underlying data requests fail.
What is the most efficient pattern for triggering a global clear of the Framework7 Auth store when an API returns a 401 Unauthorized response? Is there a built-in event or observer to re-evaluate route protection without forcing a full page reload?