Browse Source

Add password flag for authentication

For T692
pull/43/head
Christopher Davis 4 years ago
parent
commit
c6af292b2a
2 changed files with 16 additions and 8 deletions
  1. +4
    -0
      cmd/writeas/main.go
  2. +12
    -8
      commands/commands.go

+ 4
- 0
cmd/writeas/main.go View File

@@ -238,6 +238,10 @@ func main() {
Name: "verbose, v",
Usage: "Make the operation more talkative",
},
cli.StringFlag{
Name: "password, p",
Usage: "The password for the account being logged into",
},
},
},
{


+ 12
- 8
commands/commands.go View File

@@ -408,15 +408,19 @@ func CmdAuth(c *cli.Context) error {
}
}

fmt.Print("Password: ")
pass, err := gopass.GetPasswdMasked()
if err != nil {
return cli.NewExitError(fmt.Sprintf("error reading password: %v", err), 1)
}

// Validate password
// Take password from argument, and fall back to input
pass := c.String("p")
if len(pass) == 0 {
return cli.NewExitError("Please enter your password.", 1)
fmt.Print("Password: ")
pass, err := gopass.GetPasswdMasked()
if err != nil {
return cli.NewExitError(fmt.Sprintf("error reading password: %v", err), 1)
}

// Validate password
if len(pass) == 0 {
return cli.NewExitError("Please enter your password.", 1)
}
}

if config.IsTor(c) {


Loading…
Cancel
Save