Skip to content

Commit

Permalink
fix: save API key to profile
Browse files Browse the repository at this point in the history
  • Loading branch information
leggetter committed Aug 20, 2024
1 parent c642cee commit aa6dbd9
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion pkg/login/client_login.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@ import (
"fmt"
"io"
"io/ioutil"
"log"
"net/http"
"net/url"
"os"

log "github.com/sirupsen/logrus"

"github.com/briandowns/spinner"

"github.com/hookdeck/hookdeck-cli/pkg/ansi"
Expand All @@ -36,6 +37,11 @@ func Login(config *config.Config, input io.Reader) error {
var s *spinner.Spinner

if config.Profile.APIKey != "" {
log.WithFields(log.Fields{
"prefix": "login.Login",
"APIKey": config.Profile.APIKey,
}).Debug("Logging in with API key")

s = ansi.StartNewSpinner("Verifying credentials...", os.Stdout)
response, err := ValidateKey(config.APIBaseURL, config.Profile.APIKey, config.Profile.TeamID)
if err != nil {
Expand All @@ -45,6 +51,8 @@ func Login(config *config.Config, input io.Reader) error {
message := SuccessMessage(response.UserName, response.UserEmail, response.OrganizationName, response.TeamName, response.TeamMode == "console")
ansi.StopSpinner(s, message, os.Stdout)

config.Profile.SaveProfile(config.LocalConfigFile != "")

return nil
}

Expand Down

0 comments on commit aa6dbd9

Please sign in to comment.