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

Session manager times out on auth screen #22

Closed ikennaumeh closed 10 months ago

ikennaumeh commented 1 year ago

Session manager still times out on auth screen even after i stop listening or havent started listerning at all. ie. I start listening after login button is clicked.

i use the sample code presented in pub.dev

 final sessionConfig = SessionConfig(
      invalidateSessionForAppLostFocus: const Duration(seconds: 30),
      invalidateSessionForUserInactivity: const Duration(minutes: 1),
    );
    sessionConfig.stream.listen((SessionTimeoutState timeoutEvent) {
      // stop listening, as user will already be in login page
      appModel?.sessionStateStream.add(SessionState.stopListening);

      if (timeoutEvent == SessionTimeoutState.userInactivityTimeout) {
        appModel?.handleTimeoutAndLogin();
      } else if (timeoutEvent == SessionTimeoutState.appFocusTimeout) {
        appModel?.handleTimeoutAndLogin();
      }
    });  

and i dont start listening till i click the button on login. I dont understand why then it times out on login/auth screen

SankethBK commented 1 year ago

Hi @ikennaumeh , can you please post the code snippet where you are initialising SessionTimeoutManager

ikennaumeh commented 1 year ago

Here @SankethBK : SessionTimeoutManager( userActivityDebounceDuration: const Duration(seconds: 10), sessionConfig: sessionConfig, sessionStateStream: appModel?.sessionStateStream.stream, child: MaterialApp())

SankethBK commented 11 months ago

Hey sorry i missed this, the issue in above code is userActivityDebounceDuration is very high, try reducing it to 1 second