mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-12 23:01:41 +00:00
refactor(ui): trim auth comments to logic that isn't self-evident
This commit is contained in:
parent
9237fe524c
commit
08f7c188fd
2 changed files with 4 additions and 12 deletions
|
|
@ -7,16 +7,10 @@ import { useCallback, useEffect } from "react";
|
|||
import { useAuth } from "@/contexts/AuthContext";
|
||||
import { useUIConfig } from "./uiConfig/useUIConfig";
|
||||
|
||||
// Decoded-JWT fields keep the pre-consolidation `any` typing: the old hook returned
|
||||
// `any` here and ~25 call sites pass these where `string` is expected. Tightening to
|
||||
// the context's `string | null` is a follow-up that has to fix those call sites.
|
||||
// Decoded-JWT fields keep their legacy `any` typing; call sites still pass them
|
||||
// where `string` is expected, so tightening to `string | null` is a follow-up.
|
||||
type LegacyDecodedField = any;
|
||||
|
||||
/**
|
||||
* Policy hook for pages that require an authenticated user. Auth state itself
|
||||
* lives in AuthContext (single decode at the root); this hook layers on the
|
||||
* admin_ui_disabled check and the redirect-to-login side effect.
|
||||
*/
|
||||
const useAuthorized = () => {
|
||||
const router = useRouter();
|
||||
const { data: uiConfig, isLoading: isUIConfigLoading } = useUIConfig();
|
||||
|
|
|
|||
|
|
@ -77,10 +77,8 @@ export function AuthProvider({ children }: { children: React.ReactNode }) {
|
|||
};
|
||||
}, []);
|
||||
|
||||
// Side effects of a token change: drop tokens that fail to decode, sync the
|
||||
// mutable user fields, and apply any custom auth header. The reset branch runs
|
||||
// after any commit that nulls the token, so user fields cannot survive clearAuth
|
||||
// even if a stale sync was queued in the same commit.
|
||||
// Sync the mutable user fields and the custom auth header to the decoded token;
|
||||
// a token that fails to decode is cleared.
|
||||
useEffect(() => {
|
||||
if (token && !decoded) {
|
||||
clearAuth();
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue