Skip to content

Commit

Permalink
fix: logout (#212)
Browse files Browse the repository at this point in the history
  • Loading branch information
jfatta authored Mar 30, 2021
1 parent ec2d3e3 commit f1c5ab2
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions internal/cli/logout.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package cli

import (
"errors"
"fmt"

"github.com/auth0/auth0-cli/internal/prompt"
Expand All @@ -12,7 +13,7 @@ func logoutCmd(cli *cli) *cobra.Command {
Use: "logout",
Short: "Logout of a tenant's session",
Long: `auth0 logout <tenant>`,
Args: cobra.MaximumNArgs(1),
Args: cobra.MaximumNArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
// NOTE(cyx): This was mostly copy/pasted from tenants
// use command. Consider refactoring.
Expand All @@ -23,12 +24,16 @@ func logoutCmd(cli *cli) *cobra.Command {
return fmt.Errorf("Unable to load tenants due to an unexpected error: %w", err)
}

if len(tens) == 0 {
return errors.New("there are no tenants available to perform the logout")
}

tenNames := make([]string, len(tens))
for i, t := range tens {
tenNames[i] = t.Name
}

input := prompt.SelectInput("tenant", "Tenant:", "Tenant to activate", tenNames, "", true)
input := prompt.SelectInput("tenant", "Tenant:", "Tenant to logout", tenNames, tenNames[0], true)
if err := prompt.AskOne(input, &selectedTenant); err != nil {
return fmt.Errorf("An unexpected error occurred: %w", err)
}
Expand Down

0 comments on commit f1c5ab2

Please sign in to comment.