Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add option to skip-verify and pass email through args
- Loading branch information
Showing
2 changed files
with
47 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package users | ||
|
||
import ( | ||
"errors" | ||
|
||
"github.com/astronomerio/astro-cli/config" | ||
"github.com/astronomerio/astro-cli/houston" | ||
"github.com/astronomerio/astro-cli/pkg/httputil" | ||
"github.com/astronomerio/astro-cli/pkg/input" | ||
) | ||
|
||
var ( | ||
HTTP = httputil.NewHTTPClient() | ||
) | ||
|
||
// CreateUser verifies input before sending a CreateUser API call to houston | ||
func CreateUser(skipVerify bool, emailIn string) error { | ||
API := houston.NewHoustonClient(HTTP) | ||
email := emailIn | ||
|
||
if len(emailIn) == 0 { | ||
email = input.InputText("Email: ") | ||
} | ||
|
||
password, _ := input.InputPassword("Password: ") | ||
|
||
if !skipVerify { | ||
passwordVerify, _ := input.InputPassword("Re-enter Password: ") | ||
if password != passwordVerify { | ||
return errors.New("Passwords do not match, try again") | ||
} | ||
} | ||
|
||
status, houstonErr := API.CreateUser(email, password) | ||
if houstonErr != nil { | ||
return houstonErr | ||
} | ||
|
||
config.CFG.CloudAPIToken.SetProjectString(status.Token) | ||
return nil | ||
} |