Merge pull request #5890 from continuedev/dallin/fix-missing-sign-in-button
Fix missing sign in button
This commit is contained in:
commit
413f685921
3 changed files with 10 additions and 15 deletions
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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<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");
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue