mirror of
https://github.com/danswer-ai/danswer.git
synced 2025-03-17 21:32:36 +01:00
add brief comment
This commit is contained in:
parent
cebc341991
commit
8821f399f0
@ -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."""
|
||||
|
||||
|
@ -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<void>
|
||||
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user