diff --git a/backend/onyx/auth/users.py b/backend/onyx/auth/users.py index 547adc78c..4aad1412e 100644 --- a/backend/onyx/auth/users.py +++ b/backend/onyx/auth/users.py @@ -695,6 +695,7 @@ T = TypeVar("T") ID = TypeVar("ID") +# Protocol for strategies that support token refreshing without inheritance. class RefreshableStrategy(Protocol, Generic[T, ID]): """Protocol for authentication strategies that support token refreshing.""" diff --git a/web/src/hooks/useTokenRefresh.ts b/web/src/hooks/useTokenRefresh.ts index fa510506d..eadbc79f5 100644 --- a/web/src/hooks/useTokenRefresh.ts +++ b/web/src/hooks/useTokenRefresh.ts @@ -2,9 +2,11 @@ import { useState, useEffect, useRef } from "react"; import { User } from "@/lib/types"; import { NO_AUTH_USER_ID } from "@/lib/extension/constants"; -/** - * Custom hook for handling JWT token refresh for current user - */ +// Refresh token every 10 minutes (600000ms) +// This is shorter than the session expiry time to ensure tokens stay valid +const REFRESH_INTERVAL = 600000; + +// Custom hook for handling JWT token refresh for current user export function useTokenRefresh( user: User | null, onRefreshFail: () => Promise @@ -18,10 +20,6 @@ export function useTokenRefresh( useEffect(() => { if (!user || user.id === NO_AUTH_USER_ID) return; - // Refresh token every 10 minutes (600000ms) - // This is shorter than the session expiry time to ensure tokens stay valid - const REFRESH_INTERVAL = 600000; - const refreshTokenPeriodically = async () => { try { // Skip time check if this is first load - we always refresh on first load