diff --git a/cmd/common.go b/cmd/common.go index a1db8680..2f4c0e7f 100644 --- a/cmd/common.go +++ b/cmd/common.go @@ -69,12 +69,16 @@ func newKeyring(logger log.Logger, passphrase string, interactive bool) (keyring path := strings.Split(s, " unlock ")[1] logger.Log().Msgf("enter passphrase to unlock %s (this is separate from your Apple ID password): ", path) - password, err := term.ReadPassword(int(os.Stdin.Fd())) + bytes, err := term.ReadPassword(int(os.Stdin.Fd())) if err != nil { return "", errors.Wrap(err, "failed to read password") } - return string(password), nil + password := string(bytes) + password = strings.Trim(password, "\n") + password = strings.Trim(password, "\r") + + return password, nil }, }) if err != nil { diff --git a/pkg/appstore/appstore_login.go b/pkg/appstore/appstore_login.go index caf294c4..bb8c194c 100644 --- a/pkg/appstore/appstore_login.go +++ b/pkg/appstore/appstore_login.go @@ -171,7 +171,10 @@ func (a *appstore) promptForAuthCode() (string, error) { return "", errors.Wrap(err, ErrGetData.Error()) } - return strings.Trim(authCode, "\n"), nil + authCode = strings.Trim(authCode, "\n") + authCode = strings.Trim(authCode, "\r") + + return authCode, nil } func (*appstore) authDomain(authCode, guid string) string {