From fad35a7cba21a7333035548de42b0c07007f5c75 Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Wed, 28 May 2025 19:41:36 -0700 Subject: [PATCH] fix missing sign in button --- core/control-plane/AuthTypes.ts | 10 +++------- core/control-plane/client.ts | 11 +++++------ gui/src/pages/config/AccountButton.tsx | 4 ++-- 3 files changed, 10 insertions(+), 15 deletions(-) diff --git a/core/control-plane/AuthTypes.ts b/core/control-plane/AuthTypes.ts index c926efac1..3b79d91ae 100644 --- a/core/control-plane/AuthTypes.ts +++ b/core/control-plane/AuthTypes.ts @@ -13,14 +13,10 @@ export interface OnPremSessionInfo { export type ControlPlaneSessionInfo = HubSessionInfo | OnPremSessionInfo; -export function isHubSession( +export function isOnPremSession( sessionInfo: ControlPlaneSessionInfo | undefined, -): sessionInfo is HubSessionInfo { - return ( - sessionInfo !== undefined && - (sessionInfo.AUTH_TYPE === AuthType.WorkOsProd || - sessionInfo.AUTH_TYPE === AuthType.WorkOsStaging) - ); +): sessionInfo is OnPremSessionInfo { + return sessionInfo !== undefined && sessionInfo.AUTH_TYPE === AuthType.OnPrem; } export enum AuthType { diff --git a/core/control-plane/client.ts b/core/control-plane/client.ts index e3513ac2d..d2653e246 100644 --- a/core/control-plane/client.ts +++ b/core/control-plane/client.ts @@ -12,7 +12,7 @@ import fetch, { RequestInit, Response } from "node-fetch"; import { OrganizationDescription } from "../config/ProfileLifecycleManager.js"; import { IdeSettings, ModelDescription } from "../index.js"; -import { ControlPlaneSessionInfo, isHubSession } from "./AuthTypes.js"; +import { ControlPlaneSessionInfo, isOnPremSession } from "./AuthTypes.js"; import { getControlPlaneEnv } from "./env.js"; export interface ControlPlaneWorkspace { @@ -63,17 +63,16 @@ export class ControlPlaneClient { async getAccessToken(): Promise { const sessionInfo = await this.sessionInfoPromise; - return isHubSession(sessionInfo) ? sessionInfo.accessToken : undefined; + return isOnPremSession(sessionInfo) ? undefined : sessionInfo?.accessToken; } private async request(path: string, init: RequestInit): Promise { const sessionInfo = await this.sessionInfoPromise; - const hubSession = isHubSession(sessionInfo); - - const accessToken = hubSession ? sessionInfo.accessToken : undefined; + const onPremSession = isOnPremSession(sessionInfo); + const accessToken = await this.getAccessToken(); // Bearer token not necessary for on-prem auth type - if (!accessToken && hubSession) { + if (!accessToken && !onPremSession) { throw new Error("No access token"); } diff --git a/gui/src/pages/config/AccountButton.tsx b/gui/src/pages/config/AccountButton.tsx index 2d6d06b4f..d30e638a0 100644 --- a/gui/src/pages/config/AccountButton.tsx +++ b/gui/src/pages/config/AccountButton.tsx @@ -1,6 +1,6 @@ import { UserCircleIcon } from "@heroicons/react/24/solid"; -import { isHubSession } from "core/control-plane/AuthTypes"; +import { isOnPremSession } from "core/control-plane/AuthTypes"; import { SecondaryButton } from "../../components"; import { Popover, @@ -29,7 +29,7 @@ export function AccountButton() { } // No login button for on-prem deployments - if (!isHubSession(session)) { + if (isOnPremSession(session)) { return null; }