SankethBK / local_session_timeout

Redirect user to authentication page if the application doesn't receive any user interaction, or been running in the background for "x" duration.
https://pub.dev/packages/local_session_timeout
BSD 3-Clause "New" or "Revised" License
12 stars 19 forks source link

Handle SessionTimeoutManager.sessionConfig change #20

Closed arazinger closed 11 months ago

arazinger commented 1 year ago

Hi, I have a use case where SessionTimeoutManager.sessionConfig can change at any time through user settings (user can set invalidateSessionForUserInactivity timeout through settings screen/page).

When SessionTimeoutManager.sessionConfig changes, SessionTimeoutManager doesn't handle the change at all. I would expect internal timer _userInactivityTimer would be reset in this case, so the new setting would be applied immediately - currently the new setting is applied when first user activity is detected?

SankethBK commented 1 year ago

Hi @arazinger. I understand you need a functionality to refresh the sessionConfig with different values and delete all stale timers before doing so. It is possible to implement this, we can create a new stream and pass it as a parameter to SessionTimeoutManager, we can implement a function which updates sessionConfig and resets all timers whenever an object is received from stream.

Currently I am bit occupied, I can guide you with the changes and PR review if you want to implement

arazinger commented 1 year ago

Hi, I've just made a workaround similar to your proposed solution by pushing another SessionState event to the sessionStateStream after new sessionConfig is set and timer is reset. Not the prettiest solution, but works well for my case. IMHO better (and simpler) solution would be to check if sessionConfig changed inside _SessionTimeoutManagerState.didUpdateWidget and no new stream would be needed for this.