[5.x] Fix session expiry component #11501
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
tldr: This PR brings back the expected (carbon 2) behavior. It provides the remaining session seconds as a positive integer which prevents the session expiry modal appearing when not necessary.
The session expiry component exists on every control panel panel. It receives the session lifetime in sections and will begin a countdown. When it gets to about a minute, it will perform an ajax request to a route that will give the real remaining time left in the session.
If another tab was using the site in the mean time, the session would have been extended. The ajax request should reflect it.
Carbon 3 will return "diffInSeconds" as a negative number for times in the future. Since the component now receives a
negative number, it will show the "your session has expired" modal and ask you to log back in, even if it's not necessary.
This issue was only noticeable if you left a tab open for longer than the session lifetime, and were on the latest Statamic version that uses Carbon 3.