mirror of
https://github.com/passbolt/go-passbolt-cli.git
synced 2025-05-12 02:58:20 +00:00
fix Double Prompting Issue when Reading Secret Input
This commit is contained in:
parent
94165a0f3d
commit
cbf2771935
3 changed files with 6 additions and 9 deletions
|
@ -32,8 +32,7 @@ var verifyCMD = &cobra.Command{
|
|||
|
||||
userPassword := viper.GetString("userPassword")
|
||||
if userPassword == "" {
|
||||
fmt.Print("Enter Password:")
|
||||
pw, err := util.ReadPassword()
|
||||
pw, err := util.ReadPassword("Enter Password:")
|
||||
if err != nil {
|
||||
fmt.Println()
|
||||
return fmt.Errorf("Reading Password: %w", err)
|
||||
|
|
|
@ -53,8 +53,7 @@ func KeepassExport(cmd *cobra.Command, args []string) error {
|
|||
cmd.SilenceUsage = true
|
||||
|
||||
if keepassPassword == "" {
|
||||
fmt.Print("Enter Keepass Password:")
|
||||
pw, err := util.ReadPassword()
|
||||
pw, err := util.ReadPassword("Enter Keepass Password:")
|
||||
if err != nil {
|
||||
fmt.Println()
|
||||
return fmt.Errorf("Reading Keepass Password: %w", err)
|
||||
|
|
|
@ -17,11 +17,11 @@ import (
|
|||
)
|
||||
|
||||
// ReadPassword reads a Password interactively or via Pipe
|
||||
func ReadPassword() (string, error) {
|
||||
func ReadPassword(prompt string) (string, error) {
|
||||
fd := int(os.Stdin.Fd())
|
||||
var pass string
|
||||
if term.IsTerminal(fd) {
|
||||
fmt.Print("Enter Password:")
|
||||
fmt.Print(prompt)
|
||||
|
||||
inputPass, err := term.ReadPassword(fd)
|
||||
if err != nil {
|
||||
|
@ -54,7 +54,7 @@ func GetClient(ctx context.Context) (*api.Client, error) {
|
|||
|
||||
userPassword := viper.GetString("userPassword")
|
||||
if userPassword == "" {
|
||||
cliPassword, err := ReadPassword()
|
||||
cliPassword, err := ReadPassword("Enter Password:")
|
||||
if err != nil {
|
||||
fmt.Println()
|
||||
return nil, fmt.Errorf("Reading Password: %w", err)
|
||||
|
@ -94,8 +94,7 @@ func GetClient(ctx context.Context) (*api.Client, error) {
|
|||
}
|
||||
for i := 0; i < 3; i++ {
|
||||
var code string
|
||||
fmt.Print("Enter TOTP:")
|
||||
code, err := ReadPassword()
|
||||
code, err := ReadPassword("Enter TOTP:")
|
||||
if err != nil {
|
||||
fmt.Printf("\n")
|
||||
return http.Cookie{}, fmt.Errorf("Reading TOTP: %w", err)
|
||||
|
|
Loading…
Add table
Reference in a new issue