Skip to content

Commit b4f1de4

Browse files
author
vivansh12
committed
fix: trigger duplicate interactive login prompts when logged out
1 parent 6b83fdb commit b4f1de4

3 files changed

Lines changed: 12 additions & 0 deletions

File tree

pkg/cmd/copy/copy.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ type CopyStore interface {
3737
StartWorkspace(workspaceID string) (*entity.Workspace, error)
3838
GetWorkspace(workspaceID string) (*entity.Workspace, error)
3939
GetCurrentUserKeys() (*entity.UserKeys, error)
40+
GetAccessToken() (string, error)
4041
}
4142

4243
func NewCmdCopy(t *terminal.Terminal, store CopyStore, noLoginStartStore CopyStore) *cobra.Command {
@@ -65,6 +66,9 @@ func NewCmdCopy(t *terminal.Terminal, store CopyStore, noLoginStartStore CopySto
6566
}
6667

6768
func runCopyCommand(t *terminal.Terminal, cstore CopyStore, source, dest string, host bool) error {
69+
if _, err := cstore.GetAccessToken(); err != nil {
70+
return breverrors.WrapAndTrace(err)
71+
}
6872
workspaceNameOrID, remotePath, localPath, isUpload, err := parseCopyArguments(source, dest)
6973
if err != nil {
7074
return breverrors.WrapAndTrace(err)

pkg/cmd/portforward/portforward.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ type PortforwardStore interface {
3131
refresh.RefreshStore
3232
util.GetWorkspaceByNameOrIDErrStore
3333
util.MakeWorkspaceWithMetaStore
34+
GetAccessToken() (string, error)
3435
}
3536

3637
func NewCmdPortForwardSSH(pfStore PortforwardStore, t *terminal.Terminal) *cobra.Command {
@@ -87,6 +88,9 @@ func isPortAlreadyAllocatedError(err error) bool {
8788
}
8889

8990
func RunPortforward(t *terminal.Terminal, pfStore PortforwardStore, nameOrID string, portString string, useHost bool) error {
91+
if _, err := pfStore.GetAccessToken(); err != nil {
92+
return breverrors.WrapAndTrace(err)
93+
}
9094
localPort, remotePort, err := parsePortString(portString)
9195
if err != nil {
9296
return err

pkg/cmd/shell/shell.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ type ShellStore interface {
4949
refresh.RefreshStore
5050
GetOrganizations(options *store.GetOrganizationsOptions) ([]entity.Organization, error)
5151
GetWorkspaces(organizationID string, options *store.GetWorkspacesOptions) ([]entity.Workspace, error)
52+
GetAccessToken() (string, error)
5253
}
5354

5455
func NewCmdShell(t *terminal.Terminal, store ShellStore, noLoginStartStore ShellStore) *cobra.Command {
@@ -80,6 +81,9 @@ func NewCmdShell(t *terminal.Terminal, store ShellStore, noLoginStartStore Shell
8081
const pollTimeout = 10 * time.Minute
8182

8283
func runShellCommand(t *terminal.Terminal, sstore ShellStore, workspaceNameOrID string, host bool) error {
84+
if _, err := sstore.GetAccessToken(); err != nil {
85+
return breverrors.WrapAndTrace(err)
86+
}
8387
s := t.NewSpinner()
8488
target, err := util.ResolveWorkspaceOrNode(sstore, workspaceNameOrID)
8589
if err != nil {

0 commit comments

Comments
 (0)