From 03aa404d4fce6f95f747fa160c68632ec513b347 Mon Sep 17 00:00:00 2001 From: Ishaan Jaff Date: Mon, 3 Mar 2025 14:59:26 -0800 Subject: [PATCH] use utils for clearing cookies --- ui/litellm-dashboard/src/app/onboarding/page.tsx | 9 +-------- .../src/components/user_dashboard.tsx | 11 +++++++---- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/ui/litellm-dashboard/src/app/onboarding/page.tsx b/ui/litellm-dashboard/src/app/onboarding/page.tsx index ff301d7a474..e46e46fcb54 100644 --- a/ui/litellm-dashboard/src/app/onboarding/page.tsx +++ b/ui/litellm-dashboard/src/app/onboarding/page.tsx @@ -20,14 +20,7 @@ import { } from "@/components/networking"; import { jwtDecode } from "jwt-decode"; import { Form, Button as Button2, message } from "antd"; - -function getCookie(name: string) { - console.log("COOKIES", document.cookie) - const cookieValue = document.cookie - .split('; ') - .find(row => row.startsWith(name + '=')); - return cookieValue ? cookieValue.split('=')[1] : null; -} +import { getCookie } from "@/utils/cookieUtils"; export default function Onboarding() { const [form] = Form.useForm(); diff --git a/ui/litellm-dashboard/src/components/user_dashboard.tsx b/ui/litellm-dashboard/src/components/user_dashboard.tsx index 8b9f5e328f0..22b47d525fc 100644 --- a/ui/litellm-dashboard/src/components/user_dashboard.tsx +++ b/ui/litellm-dashboard/src/components/user_dashboard.tsx @@ -21,6 +21,7 @@ import { useSearchParams, useRouter } from "next/navigation"; import { Team } from "./key_team_helpers/key_list"; import { jwtDecode } from "jwt-decode"; import { Typography } from "antd"; +import { clearTokenCookies } from "@/utils/cookieUtils"; const isLocal = process.env.NODE_ENV === "development"; if (isLocal != true) { console.log = function() {}; @@ -295,14 +296,15 @@ const UserDashboard: React.FC = ({ if (userID == null || token == null) { // user is not logged in as yet + console.log("All cookies before redirect:", document.cookie); + + // Clear token cookies using the utility function + clearTokenCookies(); + const url = proxyBaseUrl ? `${proxyBaseUrl}/sso/key/generate` : `/sso/key/generate`; - - // clear cookie called "token" since user will be logging in again - document.cookie = "token=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;"; - console.log("Full URL:", url); window.location.href = url; @@ -326,6 +328,7 @@ const UserDashboard: React.FC = ({ } console.log("inside user dashboard, selected team", selectedTeam); + console.log("All cookies after redirect:", document.cookie); return (