user-story icon indicating copy to clipboard operation
user-story copied to clipboard

Fix issues with sessions.

Open SundeepChand opened this issue 3 years ago • 4 comments

More info here: https://userstory.eosdesignsystem.com/story/60e318ea62aa440015a8baff

SundeepChand avatar Jul 20 '21 07:07 SundeepChand

@SundeepChand Can I work on this?

kailash360 avatar Feb 16 '22 06:02 kailash360

Sure @kailash360

SundeepChand avatar Feb 17 '22 16:02 SundeepChand

@SundeepChand

Currently, in the application, session duration is set in the backend only. However, there is no session duration present in the cookies when the user logs in. This causes the error mentioned in the issue. So we will need to set a custom session limit in the frontend of the application.

I have thought of the following approach to this issue:

  • First when the user logs in, the timestamp for session expiration (say Session_Expiration_Time) is stored within the local storage of the application.
  • As the time flies by, we will be checking if the timestamp for current time (say Current_Time) is less than the Session_Expiration_Time. This can be implemented using a timeout tracker.
  • If the user makes any movement on the window like scrolls the page, moves the mouse on the page or any other form of interaction, then the Session_Expiration_Time is updated within the local storage

image

  • On the other hand, if the user does not interact with the application and the session expiration duration is reached i,e Current_Time > Session_Expiration_Time, then we can execute the logout logic of the application, and navigae the user to the login page.
  • When the user logs in again, the same steps will repeat.

There is also a possibility that the user can keep the user-story application open in multiple tabs at the same time. However, due to the use of local storage, the Session_Expiration_Time will remain same for all the tabs.

image

There is yet another catch in the application. If the user closes the window and then opens the app again. In this case we will need to check the expired time in the initial state. There are 2 scenarios here:

  • If user is still in an active session i.e Current_Time < Session_Expiration_Time, our solution can still handle by creating the new expired time.
  • If user opens the app after the expired time, we need to immediately execute the logout logic.

Kindly suggest, if the approach feels suitable, or if I need to make any changes.

kailash360 avatar Feb 19 '22 05:02 kailash360

@SundeepChand I have created PR #134 for this issue

kailash360 avatar Feb 25 '22 12:02 kailash360