Skip to content

Fix missing sign in button #5890

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 29, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 3 additions & 7 deletions core/control-plane/AuthTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
11 changes: 5 additions & 6 deletions core/control-plane/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -63,17 +63,16 @@ export class ControlPlaneClient {

async getAccessToken(): Promise<string | undefined> {
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<Response> {
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");
}

Expand Down
4 changes: 2 additions & 2 deletions gui/src/pages/config/AccountButton.tsx
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -29,7 +29,7 @@ export function AccountButton() {
}

// No login button for on-prem deployments
if (!isHubSession(session)) {
if (isOnPremSession(session)) {
return null;
}

Expand Down
Loading