-
Notifications
You must be signed in to change notification settings - Fork 0
Description
since the refresh interval is set in Layout.astro, the timer will reset every time a page that uses Layout.astro is loaded, resulting in tokens expiring before they are refreshed.
for example, the directus token expiration is 15min, and i have set our timer to 12min. a user logs in, starting the directus expiration timer and our refresh timer. at 11min, the user refreshes the page or navigates to a different page on the site. If that resets the refresh timer, then the refresh will not occur until 23min, at which point the access token will have already expired. in this case, the user would not have a valid token from 15min-23min.
Solution:
need to check the expiration of the access_token on page load and dynamically set the refresh timer to 2 min before access_token expires. if expiration has already passed or will pass in <2 min, refresh immediately.