You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The enableOnWindowFocus feature should not be triggered on pages that are accessible to unauthenticated users. Currently, when a user switches back to a tab containing an unauthenticated page (such as the login page of us), the refresh mechanism is still executed, which is unnecessary and potentially problematic.
In the current implementation in src/runtime/utils/refreshHandler.ts, there's an inconsistency in how enablePeriodically and enableOnWindowFocus are handled.
For enablePeriodically, there's a check for the authenticated state:
To resolve this issue and ensure consistency, we should add an authentication check for enableOnWindowFocus as well. A proposed solution is to add a condition like:
Environment
Reproduction
Describe the bug
The enableOnWindowFocus feature should not be triggered on pages that are accessible to unauthenticated users. Currently, when a user switches back to a tab containing an unauthenticated page (such as the login page of us), the refresh mechanism is still executed, which is unnecessary and potentially problematic.
In the current implementation in
src/runtime/utils/refreshHandler.ts
, there's an inconsistency in howenablePeriodically
andenableOnWindowFocus
are handled.For
enablePeriodically
, there's a check for the authenticated state:nuxt-auth/src/runtime/utils/refreshHandler.ts
Lines 35 to 42 in 9295d1f
However, for
enableOnWindowFocus
, no such check exists:nuxt-auth/src/runtime/utils/refreshHandler.ts
Lines 72 to 79 in 9295d1f
To resolve this issue and ensure consistency, we should add an authentication check for
enableOnWindowFocus
as well. A proposed solution is to add a condition like:This change would prevent unnecessary refresh attempts on unauthenticated pages and align the behavior with
enablePeriodically
.Thanks.
Additional context
No response
Logs
FetchError: [POST] "/app/main/api/auth/refresh": 403
The text was updated successfully, but these errors were encountered: