Skip to content

Commit

Permalink
Merge pull request #177 from superfly/fixes-for-list-apps-auth
Browse files Browse the repository at this point in the history
Fixes for err no auth crashes
  • Loading branch information
codepope committed Jun 26, 2020
2 parents 4dfb949 + d00329d commit a27b183
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 10 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,4 @@ docstrings/gen.go
/.idea/misc.xml
/.idea/modules.xml
/.idea/vcs.xml
.vscode/launch.json
3 changes: 0 additions & 3 deletions api/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,6 @@ type Client struct {
}

func NewClient(accessToken string, version string) *Client {
if accessToken == "" {
return nil, errors.New("No api access token available. Please login with 'flyctl auth signup' or 'flyctl auth login'")
}

httpClient, _ := newHTTPClient()

Expand Down
6 changes: 2 additions & 4 deletions cmd/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@ package cmd
import (
"context"
"fmt"
"github.com/superfly/flyctl/cmdctx"
"io"
"os"
"os/signal"
"path"
"path/filepath"
"syscall"

"github.com/superfly/flyctl/cmdctx"

"github.com/spf13/cobra"
"github.com/spf13/viper"
"github.com/superfly/flyctl/flyctl"
Expand Down Expand Up @@ -207,9 +208,6 @@ func requireSession(cmd *Command) Initializer {
if !ctx.Client.Authenticated() {
return client.ErrNoAuthToken
}

// TODO: prompt to begin auth

return nil
},
}
Expand Down
7 changes: 4 additions & 3 deletions cmd/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ package cmd

import (
"fmt"
"github.com/superfly/flyctl/cmdctx"
"os"
"strings"

"github.com/superfly/flyctl/cmdctx"

"github.com/spf13/cobra"
"github.com/superfly/flyctl/docstrings"
)
Expand All @@ -23,7 +24,7 @@ func newListCommand() *Command {
}

laks := docstrings.Get("list.apps")
listAppsCmd := BuildCommand(listCmd, runListApps, laks.Usage, laks.Short, laks.Long, os.Stdout)
listAppsCmd := BuildCommand(listCmd, runListApps, laks.Usage, laks.Short, laks.Long, os.Stdout, requireSession)

listAppsCmd.AddStringFlag(StringFlagOpts{
Name: "org",
Expand All @@ -38,7 +39,7 @@ func newListCommand() *Command {
})

loks := docstrings.Get("list.orgs")
BuildCommand(listCmd, runListOrgs, loks.Usage, loks.Short, loks.Long, os.Stdout)
BuildCommand(listCmd, runListOrgs, loks.Usage, loks.Short, loks.Long, os.Stdout, requireSession)

return listCmd
}
Expand Down

0 comments on commit a27b183

Please sign in to comment.