mirror of
https://github.com/passbolt/go-passbolt-cli.git
synced 2025-05-15 03:58:21 +00:00
Replace usages of term.ReadPassword with util.ReadPassword
This commit is contained in:
parent
bfbc15bd0d
commit
440f41a2af
3 changed files with 5 additions and 10 deletions
|
@ -2,13 +2,11 @@ package cmd
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"syscall"
|
|
||||||
|
|
||||||
"github.com/passbolt/go-passbolt-cli/util"
|
"github.com/passbolt/go-passbolt-cli/util"
|
||||||
"github.com/passbolt/go-passbolt/api"
|
"github.com/passbolt/go-passbolt/api"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
"github.com/spf13/viper"
|
"github.com/spf13/viper"
|
||||||
"golang.org/x/term"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// verifyCMD represents the verify command
|
// verifyCMD represents the verify command
|
||||||
|
@ -35,12 +33,12 @@ var verifyCMD = &cobra.Command{
|
||||||
userPassword := viper.GetString("userPassword")
|
userPassword := viper.GetString("userPassword")
|
||||||
if userPassword == "" {
|
if userPassword == "" {
|
||||||
fmt.Print("Enter Password:")
|
fmt.Print("Enter Password:")
|
||||||
bytepw, err := term.ReadPassword(int(syscall.Stdin))
|
pw, err := util.ReadPassword()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println()
|
fmt.Println()
|
||||||
return fmt.Errorf("Reading Password: %w", err)
|
return fmt.Errorf("Reading Password: %w", err)
|
||||||
}
|
}
|
||||||
userPassword = string(bytepw)
|
userPassword = pw
|
||||||
fmt.Println()
|
fmt.Println()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,6 @@ import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"syscall"
|
|
||||||
|
|
||||||
"github.com/passbolt/go-passbolt-cli/util"
|
"github.com/passbolt/go-passbolt-cli/util"
|
||||||
"github.com/passbolt/go-passbolt/api"
|
"github.com/passbolt/go-passbolt/api"
|
||||||
|
@ -13,7 +12,6 @@ import (
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
"github.com/tobischo/gokeepasslib/v3"
|
"github.com/tobischo/gokeepasslib/v3"
|
||||||
w "github.com/tobischo/gokeepasslib/v3/wrappers"
|
w "github.com/tobischo/gokeepasslib/v3/wrappers"
|
||||||
"golang.org/x/term"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// KeepassExportCmd Exports a Passbolt Keepass
|
// KeepassExportCmd Exports a Passbolt Keepass
|
||||||
|
@ -56,12 +54,12 @@ func KeepassExport(cmd *cobra.Command, args []string) error {
|
||||||
|
|
||||||
if keepassPassword == "" {
|
if keepassPassword == "" {
|
||||||
fmt.Print("Enter Keepass Password:")
|
fmt.Print("Enter Keepass Password:")
|
||||||
bytepw, err := term.ReadPassword(int(syscall.Stdin))
|
pw, err := util.ReadPassword()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println()
|
fmt.Println()
|
||||||
return fmt.Errorf("Reading Keepass Password: %w", err)
|
return fmt.Errorf("Reading Keepass Password: %w", err)
|
||||||
}
|
}
|
||||||
keepassPassword = string(bytepw)
|
keepassPassword = pw
|
||||||
fmt.Println()
|
fmt.Println()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -97,12 +97,11 @@ func GetClient(ctx context.Context) (*api.Client, error) {
|
||||||
for i := 0; i < 3; i++ {
|
for i := 0; i < 3; i++ {
|
||||||
var code string
|
var code string
|
||||||
fmt.Print("Enter TOTP:")
|
fmt.Print("Enter TOTP:")
|
||||||
bytepw, err := term.ReadPassword(int(syscall.Stdin))
|
code, err := ReadPassword()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Printf("\n")
|
fmt.Printf("\n")
|
||||||
return http.Cookie{}, fmt.Errorf("Reading TOTP: %w", err)
|
return http.Cookie{}, fmt.Errorf("Reading TOTP: %w", err)
|
||||||
}
|
}
|
||||||
code = string(bytepw)
|
|
||||||
fmt.Printf("\n")
|
fmt.Printf("\n")
|
||||||
req := api.MFAChallangeResponse{
|
req := api.MFAChallangeResponse{
|
||||||
TOTP: code,
|
TOTP: code,
|
||||||
|
|
Loading…
Add table
Reference in a new issue