Skip to content

Show dialog warning users their session is about to expire #5890

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
avernet opened this issue Jul 6, 2023 · 9 comments
Closed

Show dialog warning users their session is about to expire #5890

avernet opened this issue Jul 6, 2023 · 9 comments

Comments

@avernet
Copy link
Collaborator

avernet commented Jul 6, 2023

+1 from customer

@avernet
Copy link
Collaborator Author

avernet commented Jul 10, 2023

Ideally, we should log users out when we tell them that the session has expired. We can easily create a service to invalidate the session, but we wouldn't want to call it too early. The issue is that right now we keep track of newestEventTime on a per page basis, and update that value when we send an Ajax request (see AjaxEventQueue.scala). If users have multiple tabs open, that value might be too pessimistic: if a user is still active on tab 1, we wouldn't want tab 2 to think the session should expire and log the user out.

So we need this newestEventTime to be shared across tabs, which can be done with localStorage. However, how can we know that users on 2 tabs are logged in the same server session? These days, cookies like JSESSIONID are marked HttpOnly, so relying on that value is most likely not an option. On page load, the server-side code could send the browser a session id, and then our client-side code could keep track in localStorage of a sessionId → newestEventTime. We'll need to think this over before going ahead with the implementation.

@avernet
Copy link
Collaborator Author

avernet commented Jul 11, 2023

We now have #5896 for the point discussed in my previous comment. And for this issue proper, we're just missing the:

  • Doc

@ebruchez
Copy link
Collaborator

ebruchez commented Aug 2, 2023

  • Form Builder JavaScript crashes upon load because fr-session-expiration-dialog is not present in that case
    • Should Form Builder have this? If so, included it, else JavaScript should not assume presence of dialog.

@ebruchez
Copy link
Collaborator

RESOLUTION: Dialog should also be present in Form Builder.

@ebruchez
Copy link
Collaborator

ebruchez commented Aug 10, 2023

  • cherry-pick on master

obruchez pushed a commit that referenced this issue Aug 24, 2023
obruchez pushed a commit that referenced this issue Aug 24, 2023
- Multiple messages shown on session expired
- Avoid code duplication in `updateDialog`
- Renew session button: fix background
- Pause requests while the dialog is shown
obruchez pushed a commit that referenced this issue Aug 24, 2023
@obruchez
Copy link
Collaborator

obruchez commented Aug 25, 2023

  • remaining bug: dialog doesn't show on pages using Bootstrap 5

@avernet avernet assigned obruchez and avernet and unassigned avernet Aug 28, 2023
@avernet
Copy link
Collaborator Author

avernet commented Sep 7, 2023

  • Investigate possible problem where dialog shown in hidden tab does not disappear when renewing in other tab
    • May be useful: Page Visibility API @ebruchez was referring to, I think: can register listener on visibilitychange, and do something when ocument.visibilityState === "visible" (what to do would be easy if we were to also store newestEventTime in localStorage).
    • Probably unrelated (but something I didn't know!): chrome://discards/ can be used to manually discard pages and more, but not, as far as I can see, to suspend/freeze tabs.

obruchez added a commit that referenced this issue Sep 11, 2023
@obruchez
Copy link
Collaborator

obruchez commented Sep 11, 2023

Fixed (removed fade class on modal, with comment). The problem was that the "expiring" dialog could not be hidden (hide function from Bootstrap) when the tab is not visible, i.e. when the session is renewed from another tab. The fade effect apparently slightly changes the behavior of the modal, in the sense that the effect will apparently not be triggered before the tab is visible (?). So the hide function is indeed called when the tab is invisible, but when the tab is shown, the effect will actually be triggered and the modal will be shown again. To avoid the extra complexity to support this case, the fade effect has been removed and a comment has been added next to the modal definition.

@ebruchez
Copy link
Collaborator

Doc

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Development

No branches or pull requests

3 participants