@@ -32,13 +32,37 @@ type Links struct {
3232
3333// Login function is used to obtain credentials via hookdeck dashboard.
3434func Login (config * config.Config , input io.Reader ) error {
35+ var s * spinner.Spinner
36+
37+ if config .Profile .APIKey != "" {
38+ s = ansi .StartNewSpinner ("Verifying CLI Key..." , os .Stdout )
39+ response , err := ValidateKey (config .APIBaseURL , config .Profile .APIKey )
40+ if err != nil {
41+ return err
42+ }
43+
44+ config .Profile .ClientID = response .ClientID
45+ config .Profile .DisplayName = response .UserName
46+ config .Profile .TeamName = response .TeamName
47+ config .Profile .TeamMode = response .TeamMode
48+ config .Profile .TeamID = response .TeamID
49+
50+ profileErr := config .Profile .CreateProfile ()
51+ if profileErr != nil {
52+ return profileErr
53+ }
54+
55+ message := SuccessMessage (response .UserName , response .TeamName , config .Profile .TeamMode == "console" )
56+ ansi .StopSpinner (s , message , os .Stdout )
57+
58+ return nil
59+ }
60+
3561 links , err := getLinks (config .APIBaseURL , config .Profile .DeviceName )
3662 if err != nil {
3763 return err
3864 }
3965
40- var s * spinner.Spinner
41-
4266 if isSSH () || ! canOpenBrowser () {
4367 fmt .Printf ("To authenticate with Hookdeck, please go to: %s\n " , links .BrowserURL )
4468
@@ -72,13 +96,15 @@ func Login(config *config.Config, input io.Reader) error {
7296 config .Profile .ClientID = response .ClientID
7397 config .Profile .DisplayName = response .UserName
7498 config .Profile .TeamName = response .TeamName
99+ config .Profile .TeamMode = response .TeamMode
100+ config .Profile .TeamID = response .TeamID
75101
76102 profileErr := config .Profile .CreateProfile ()
77103 if profileErr != nil {
78104 return profileErr
79105 }
80106
81- message := SuccessMessage (response .UserName , response .TeamName )
107+ message := SuccessMessage (response .UserName , response .TeamName , response . TeamMode == "console" )
82108 ansi .StopSpinner (s , message , os .Stdout )
83109
84110 return nil
@@ -118,6 +144,8 @@ func GuestLogin(config *config.Config) (string, error) {
118144 config .Profile .ClientID = response .ClientID
119145 config .Profile .DisplayName = response .UserName
120146 config .Profile .TeamName = response .TeamName
147+ config .Profile .TeamMode = response .TeamMode
148+ config .Profile .TeamID = response .TeamID
121149
122150 profileErr := config .Profile .CreateProfile ()
123151 if profileErr != nil {
0 commit comments