Skip to content

Commit 413f685

Browse files
authored
Merge pull request #5890 from continuedev/dallin/fix-missing-sign-in-button
Fix missing sign in button
2 parents 9d24e48 + fad35a7 commit 413f685

File tree

3 files changed

+10
-15
lines changed

3 files changed

+10
-15
lines changed

core/control-plane/AuthTypes.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,10 @@ export interface OnPremSessionInfo {
1313

1414
export type ControlPlaneSessionInfo = HubSessionInfo | OnPremSessionInfo;
1515

16-
export function isHubSession(
16+
export function isOnPremSession(
1717
sessionInfo: ControlPlaneSessionInfo | undefined,
18-
): sessionInfo is HubSessionInfo {
19-
return (
20-
sessionInfo !== undefined &&
21-
(sessionInfo.AUTH_TYPE === AuthType.WorkOsProd ||
22-
sessionInfo.AUTH_TYPE === AuthType.WorkOsStaging)
23-
);
18+
): sessionInfo is OnPremSessionInfo {
19+
return sessionInfo !== undefined && sessionInfo.AUTH_TYPE === AuthType.OnPrem;
2420
}
2521

2622
export enum AuthType {

core/control-plane/client.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import fetch, { RequestInit, Response } from "node-fetch";
1212
import { OrganizationDescription } from "../config/ProfileLifecycleManager.js";
1313
import { IdeSettings, ModelDescription } from "../index.js";
1414

15-
import { ControlPlaneSessionInfo, isHubSession } from "./AuthTypes.js";
15+
import { ControlPlaneSessionInfo, isOnPremSession } from "./AuthTypes.js";
1616
import { getControlPlaneEnv } from "./env.js";
1717

1818
export interface ControlPlaneWorkspace {
@@ -63,17 +63,16 @@ export class ControlPlaneClient {
6363

6464
async getAccessToken(): Promise<string | undefined> {
6565
const sessionInfo = await this.sessionInfoPromise;
66-
return isHubSession(sessionInfo) ? sessionInfo.accessToken : undefined;
66+
return isOnPremSession(sessionInfo) ? undefined : sessionInfo?.accessToken;
6767
}
6868

6969
private async request(path: string, init: RequestInit): Promise<Response> {
7070
const sessionInfo = await this.sessionInfoPromise;
71-
const hubSession = isHubSession(sessionInfo);
72-
73-
const accessToken = hubSession ? sessionInfo.accessToken : undefined;
71+
const onPremSession = isOnPremSession(sessionInfo);
72+
const accessToken = await this.getAccessToken();
7473

7574
// Bearer token not necessary for on-prem auth type
76-
if (!accessToken && hubSession) {
75+
if (!accessToken && !onPremSession) {
7776
throw new Error("No access token");
7877
}
7978

gui/src/pages/config/AccountButton.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { UserCircleIcon } from "@heroicons/react/24/solid";
22

3-
import { isHubSession } from "core/control-plane/AuthTypes";
3+
import { isOnPremSession } from "core/control-plane/AuthTypes";
44
import { SecondaryButton } from "../../components";
55
import {
66
Popover,
@@ -29,7 +29,7 @@ export function AccountButton() {
2929
}
3030

3131
// No login button for on-prem deployments
32-
if (!isHubSession(session)) {
32+
if (isOnPremSession(session)) {
3333
return null;
3434
}
3535

0 commit comments

Comments
 (0)