Skip to content

Commit

Permalink
handle multiple return values from gopass
Browse files Browse the repository at this point in the history
  • Loading branch information
timothyknight committed Jan 21, 2016
1 parent 2f69644 commit 8124765
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions cli/hydra-host/handler/account.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,24 @@ type Account struct {

func getPassword() (password string) {
fmt.Println("Password: ")
password = string(gopass.GetPasswd())
if password == "" {
pwd, err := gopass.GetPasswd()
if err != nil {
fmt.Errorf("Error: %s", err)
return getPassword()
}
password = string(pwd);
if string(pwd) == "" {
fmt.Println("You did not provide a password. Please try again.")
return getPassword()
}

fmt.Println("Confirm password: ")
if password != string(gopass.GetPasswd()) {
confirm, err := gopass.GetPasswd()
if err != nil {
fmt.Errorf("Error: %s", err)
return getPassword()
}
if password != string(confirm) {
fmt.Println("Password and confirmation do not match. Please try again.")
return getPassword()
}
Expand Down

0 comments on commit 8124765

Please sign in to comment.