Skip to content

Commit 962ccad

Browse files
committed
revert: login specific prompt logic
1 parent 62770ba commit 962ccad

2 files changed

Lines changed: 9 additions & 35 deletions

File tree

cmd/auth/login.go

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@ import (
1818
"context"
1919
"fmt"
2020

21-
"github.com/slackapi/slack-cli/internal/config"
22-
"github.com/slackapi/slack-cli/internal/experiment"
2321
"github.com/slackapi/slack-cli/internal/iostreams"
2422
authpkg "github.com/slackapi/slack-cli/internal/pkg/auth"
2523
"github.com/slackapi/slack-cli/internal/shared"
@@ -111,7 +109,7 @@ func RunLoginCommand(clients *shared.ClientFactory, cmd *cobra.Command) (types.S
111109
return types.SlackAuth{}, err
112110
}
113111
if selectedAuth.Token != "" {
114-
printAuthSuccess(cmd, clients.Config, clients.IO, credentialsPath, selectedAuth.Token)
112+
printAuthSuccess(cmd, clients.IO, credentialsPath, selectedAuth.Token)
115113
printAuthNextSteps(ctx, clients)
116114
}
117115
return selectedAuth, err
@@ -121,14 +119,14 @@ func RunLoginCommand(clients *shared.ClientFactory, cmd *cobra.Command) (types.S
121119
if err != nil {
122120
return types.SlackAuth{}, err
123121
} else {
124-
printAuthSuccess(cmd, clients.Config, clients.IO, credentialsPath, selectedAuth.Token)
122+
printAuthSuccess(cmd, clients.IO, credentialsPath, selectedAuth.Token)
125123
printAuthNextSteps(ctx, clients)
126124
}
127125

128126
return selectedAuth, nil
129127
}
130128

131-
func printAuthSuccess(cmd *cobra.Command, config *config.Config, IO iostreams.IOStreamer, credentialsPath string, token string) {
129+
func printAuthSuccess(cmd *cobra.Command, IO iostreams.IOStreamer, credentialsPath string, token string) {
132130
ctx := cmd.Context()
133131

134132
var secondaryLog string
@@ -138,13 +136,7 @@ func printAuthSuccess(cmd *cobra.Command, config *config.Config, IO iostreams.IO
138136
secondaryLog = fmt.Sprintf("Service token:\n\n %s\n\nMake sure to copy the token now and save it safely.", token)
139137
}
140138

141-
// The legacy prompt leaves no blank line before the success message, so
142-
// print one here. The Charm-based prompt already handles spacing.
143-
if !config.WithExperimentOn(experiment.Charm) {
144-
IO.PrintInfo(ctx, false, "")
145-
}
146-
147-
IO.PrintInfo(ctx, false, "%s", style.Sectionf(style.TextSection{
139+
IO.PrintInfo(ctx, false, "\n%s", style.Sectionf(style.TextSection{
148140
Emoji: "key",
149141
Text: "You've successfully authenticated!",
150142
Secondary: []string{secondaryLog},

internal/pkg/auth/login.go

Lines changed: 5 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,10 @@ import (
2020
"strings"
2121
"time"
2222

23-
"github.com/charmbracelet/huh"
2423
"github.com/opentracing/opentracing-go"
2524
"github.com/slackapi/slack-cli/internal/api"
2625
"github.com/slackapi/slack-cli/internal/auth"
2726
"github.com/slackapi/slack-cli/internal/config"
28-
"github.com/slackapi/slack-cli/internal/experiment"
2927
"github.com/slackapi/slack-cli/internal/iostreams"
3028
"github.com/slackapi/slack-cli/internal/pkg/version"
3129
"github.com/slackapi/slack-cli/internal/shared"
@@ -142,27 +140,11 @@ func createNewAuth(ctx context.Context, apiClient api.APIInterface, authClient a
142140
return types.SlackAuth{}, "", err
143141
}
144142

145-
challengeCode := ""
146-
if !config.WithExperimentOn(experiment.Charm) {
147-
challengeCode, err = io.InputPrompt(ctx, "Enter challenge code", iostreams.InputPromptConfig{
148-
Required: true,
149-
})
150-
if err != nil {
151-
return types.SlackAuth{}, "", err
152-
}
153-
} else {
154-
form := huh.NewForm(
155-
huh.NewGroup(
156-
huh.NewInput().
157-
Title("Enter challenge code").
158-
Validate(huh.ValidateMinLength(1)).
159-
Value(&challengeCode),
160-
),
161-
)
162-
err := form.Run()
163-
if err != nil {
164-
return types.SlackAuth{}, "", err
165-
}
143+
challengeCode, err := io.InputPrompt(ctx, "Enter challenge code", iostreams.InputPromptConfig{
144+
Required: true,
145+
})
146+
if err != nil {
147+
return types.SlackAuth{}, "", err
166148
}
167149

168150
authExchangeRes, err := apiClient.ExchangeAuthTicket(ctx, authTicket, challengeCode, version.Get())

0 commit comments

Comments
 (0)