VSN-2933/ feat(auth): automatic logout on email change
When an admin changes a user's or representative's email from the bo, the logged-in mobile user must be automatically disconnected.
Changes
Mobile-side detection
-
config/api/authEvents.ts— lightweight event emitter:emitUnauthorized()notifies all subscribers,onUnauthorized()returns an unsubscribe function -
config/api/client.ts— 401 Axios interceptor now callsemitUnauthorized()after clearing storage. AddedX-Client-Type: vsn-mobileheader on all requests so the gateway can target only the mobile app -
store/profileStore.ts— email mismatch detection insidefetchProfile(): if the representative's or passenger's email in the database no longer matches the stored session email →emitUnauthorized()+ throwunauthorized -
app/_layout.tsx— subscribes toonUnauthorized()to triggerlogout(), AppState listener to re-check the session when the app comes back to the foreground. Uses awasAuthenticatedref to prevent navigation conflict withindex.tsxon startup (fixes infinite loop / maximum update depth error)