Skip to content

VSN-2933/ feat(auth): automatic logout on email change

fatima senan a demandé de fusionner feature/VSN-2933 vers develop

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 calls emitUnauthorized() after clearing storage. Added X-Client-Type: vsn-mobile header on all requests so the gateway can target only the mobile app
  • store/profileStore.ts — email mismatch detection inside fetchProfile(): if the representative's or passenger's email in the database no longer matches the stored session email → emitUnauthorized() + throw unauthorized
  • app/_layout.tsx — subscribes to onUnauthorized() to trigger logout(), AppState listener to re-check the session when the app comes back to the foreground. Uses a wasAuthenticated ref to prevent navigation conflict with index.tsx on startup (fixes infinite loop / maximum update depth error)

Rapports de requête de fusion