fix(user_dashboard.tsx): initial commit using user id from jwt instead of url

This commit is contained in:
Krrish Dholakia 2025-04-21 15:25:59 -07:00
parent 03245c732a
commit 9ff4fa56a7
2 changed files with 12 additions and 2 deletions

View file

@ -98,8 +98,8 @@ export default function CreateKeyPage() {
const searchParams = useSearchParams()!;
const [modelData, setModelData] = useState<any>({ data: [] });
const [token, setToken] = useState<string | null>(null);
const [userID, setUserID] = useState<string | null>(null);
const userID = searchParams.get("userID");
const invitation_id = searchParams.get("invitation_id");
// Get page from URL, default to 'api-keys' if not present
@ -177,6 +177,10 @@ export default function CreateKeyPage() {
if (decoded.auth_header_name) {
setGlobalLitellmHeaderName(decoded.auth_header_name);
}
if (decoded.user_id) {
setUserID(decoded.user_id);
}
}
}, [token]);

View file

@ -295,7 +295,13 @@ const UserDashboard: React.FC<UserDashboardProps> = ({
)
}
if (userID == null || token == null) {
if (userID == null) {
return (
<h1>User ID is not set</h1>
);
}
if (token == null) {
// user is not logged in as yet
console.log("All cookies before redirect:", document.cookie);