From b4f1de49eaa6ce63084ebecae8c102278256339c Mon Sep 17 00:00:00 2001 From: vivansh12 Date: Wed, 20 May 2026 10:03:48 +0000 Subject: [PATCH] fix: trigger duplicate interactive login prompts when logged out --- pkg/cmd/copy/copy.go | 4 ++++ pkg/cmd/portforward/portforward.go | 4 ++++ pkg/cmd/shell/shell.go | 4 ++++ 3 files changed, 12 insertions(+) diff --git a/pkg/cmd/copy/copy.go b/pkg/cmd/copy/copy.go index 5aadf4efd..c35bd3b47 100644 --- a/pkg/cmd/copy/copy.go +++ b/pkg/cmd/copy/copy.go @@ -37,6 +37,7 @@ type CopyStore interface { StartWorkspace(workspaceID string) (*entity.Workspace, error) GetWorkspace(workspaceID string) (*entity.Workspace, error) GetCurrentUserKeys() (*entity.UserKeys, error) + GetAccessToken() (string, error) } func NewCmdCopy(t *terminal.Terminal, store CopyStore, noLoginStartStore CopyStore) *cobra.Command { @@ -65,6 +66,9 @@ func NewCmdCopy(t *terminal.Terminal, store CopyStore, noLoginStartStore CopySto } func runCopyCommand(t *terminal.Terminal, cstore CopyStore, source, dest string, host bool) error { + if _, err := cstore.GetAccessToken(); err != nil { + return breverrors.WrapAndTrace(err) + } workspaceNameOrID, remotePath, localPath, isUpload, err := parseCopyArguments(source, dest) if err != nil { return breverrors.WrapAndTrace(err) diff --git a/pkg/cmd/portforward/portforward.go b/pkg/cmd/portforward/portforward.go index d0a6fa977..1b7dd8480 100644 --- a/pkg/cmd/portforward/portforward.go +++ b/pkg/cmd/portforward/portforward.go @@ -31,6 +31,7 @@ type PortforwardStore interface { refresh.RefreshStore util.GetWorkspaceByNameOrIDErrStore util.MakeWorkspaceWithMetaStore + GetAccessToken() (string, error) } func NewCmdPortForwardSSH(pfStore PortforwardStore, t *terminal.Terminal) *cobra.Command { @@ -87,6 +88,9 @@ func isPortAlreadyAllocatedError(err error) bool { } func RunPortforward(t *terminal.Terminal, pfStore PortforwardStore, nameOrID string, portString string, useHost bool) error { + if _, err := pfStore.GetAccessToken(); err != nil { + return breverrors.WrapAndTrace(err) + } localPort, remotePort, err := parsePortString(portString) if err != nil { return err diff --git a/pkg/cmd/shell/shell.go b/pkg/cmd/shell/shell.go index d0c6482ed..47ee39254 100644 --- a/pkg/cmd/shell/shell.go +++ b/pkg/cmd/shell/shell.go @@ -49,6 +49,7 @@ type ShellStore interface { refresh.RefreshStore GetOrganizations(options *store.GetOrganizationsOptions) ([]entity.Organization, error) GetWorkspaces(organizationID string, options *store.GetWorkspacesOptions) ([]entity.Workspace, error) + GetAccessToken() (string, error) } func NewCmdShell(t *terminal.Terminal, store ShellStore, noLoginStartStore ShellStore) *cobra.Command { @@ -80,6 +81,9 @@ func NewCmdShell(t *terminal.Terminal, store ShellStore, noLoginStartStore Shell const pollTimeout = 10 * time.Minute func runShellCommand(t *terminal.Terminal, sstore ShellStore, workspaceNameOrID string, host bool) error { + if _, err := sstore.GetAccessToken(); err != nil { + return breverrors.WrapAndTrace(err) + } s := t.NewSpinner() target, err := util.ResolveWorkspaceOrNode(sstore, workspaceNameOrID) if err != nil {