jeudi 17 juin 2021

What is a good practice to route to login screen when auth token expires during an ongoing session?

What's a good design principle to route a user to login screen when their token expires mid-session? (either foreground or background)

I'm leaning towards an approach that uses an Event Bus (maybe a BehaviorSubject) to observe updates on the view/presentation layer and upon processing a logout event starting the LoginActivity with - FLAG_ACTIVITY_NEW_TASK | FLAG_ACTIVITY_CLEAR_TASK

The problem I'm facing is how to ensure there's no data race conditions that could lead to non-fatals or crashes.

For example a user could have started any activity lets say FooActivity (through an interaction) and maybe a headless call leads to force logout, so even if I process the event on main thread FooActivity may get created at a later time and wrongly assume that the session is active.

Aucun commentaire:

Enregistrer un commentaire