Repository navigation
feat(platform): warn and sign out idle sessions client-side - #1810
Conversation
Completes the session idle timeout (#1502). The server already enforces the window (Better Auth rejects an over-idle session on the next request when SESSION_IDLE_TIMEOUT_MINUTES is set). This adds the matching client UX so a user is warned and signed out proactively instead of silently 401-ing on their next action. - useSessionIdleWatchdog watches local input (mousemove/keydown/scroll/…), shows a warning toast one minute before the cut-off with a "Stay signed in" action, and calls authClient.signOut() + redirects to /log-in at the window. Cross-tab activity is shared via localStorage so an idle background tab doesn't sign out a user working in another. No-op when the timeout is unset. - The validated window is exposed to the client via window.__ENV__ (server.ts + the dev inject-env plugin) and read through a typed getEnv overload; it is omitted entirely when the feature is off. - Mounted in the authenticated dashboard layout. en/de/fr strings added. Tests: fake-timer coverage for the disabled, warn→sign-out, activity-reset, and warning-dismissal paths. Refs #1502, #1803
|
Warning Review limit reached
More reviews will be available in 42 minutes and 15 seconds. Learn how PR review limits work. Your organization has run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (9)
✨ Finishing Touches🧪 Generate unit tests (beta)
Warning Billing warning: we have not been able to collect payment for this subscription for more than 72 hours. Please update the payment method or pay any pending invoices in Billing to avoid service interruption. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
What
Completes the session idle timeout (#1502) with its client-side UX. The server enforcement merged in #1808 — Better Auth rejects an over-idle session on the next request when
SESSION_IDLE_TIMEOUT_MINUTESis set. This adds the matching watchdog so a user is warned and signed out proactively instead of silently 401-ing on their next action. Part of the security baseline epic.How
useSessionIdleWatchdogwatches local input (mousemove,mousedown,keydown,touchstart,scroll,wheel, plusvisibilitychange), shows a warning toast one minute before the cut-off with a Stay signed in action, and at the window callsauthClient.signOut()then hard-redirects to/log-in(full reload to flush Convex/React-Query/auth state, matching the existing sign-out precedent).localStorageand re-read each tick, so an idle background tab doesn't sign out a user who is active in another tab — mirroring the server's sliding window.window.__ENV__(server.ts+ the devinject-envplugin) and read through a typedgetEnvoverload; it is omitted entirely when the feature is off.en/de/frstrings added.Tests
use-session-idle-watchdog.test.tsx— fake-timer coverage for: no-op when unconfigured, warn-then-sign-out at the thresholds, activity resets the timer, and the warning is dismissed when the user returns (4 cases).Verification
typecheck·lint·test(ui + server) · i18n parity/usage all green. CodeRabbit applied (documented the intentional hard reload; added a focus-visible ring +motion-reduceto the toast action).Refs #1502. Tracked under the security baseline epic #1803.