Merge pull request #18 from passbolt/fix-minor-issues

Fix minor issues
This commit is contained in:
Samuel Lorch 2022-12-30 11:36:27 +01:00 committed by GitHub
commit 423dfb020c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 10 additions and 13 deletions

View file

@ -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)

View file

@ -55,7 +55,7 @@ func GroupList(cmd *cobra.Command, args []string) error {
defer client.Logout(context.TODO())
cmd.SilenceUsage = true
resources, err := client.GetGroups(ctx, &api.GetGroupsOptions{
groups, err := client.GetGroups(ctx, &api.GetGroupsOptions{
FilterHasUsers: users,
FilterHasManagers: managers,
})
@ -65,14 +65,14 @@ func GroupList(cmd *cobra.Command, args []string) error {
data := pterm.TableData{columns}
for _, resource := range resources {
for _, group := range groups {
entry := make([]string, len(columns))
for i := range columns {
switch strings.ToLower(columns[i]) {
case "id":
entry[i] = resource.ID
entry[i] = group.ID
case "name":
entry[i] = shellescape.StripUnsafe(resource.Name)
entry[i] = shellescape.StripUnsafe(group.Name)
default:
cmd.SilenceUsage = false
return fmt.Errorf("Unknown Column: %v", columns[i])

View file

@ -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)

View file

@ -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)