mirror of
https://github.com/writeas/writeas-cli
synced 2025-07-22 22:08:13 +00:00
Merge pull request #43 from writeas/T692
Add password flag for authentication Closes T692
This commit is contained in:
commit
62e03522f7
@ -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",
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
|
@ -408,15 +408,20 @@ 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)
|
||||
}
|
||||
// Take password from argument, and fall back to input
|
||||
pass := c.String("p")
|
||||
if pass == "" {
|
||||
fmt.Print("Password: ")
|
||||
enteredPass, 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)
|
||||
// Validate password
|
||||
if len(enteredPass) == 0 {
|
||||
return cli.NewExitError("Please enter your password.", 1)
|
||||
}
|
||||
pass = string(enteredPass)
|
||||
}
|
||||
|
||||
if config.IsTor(c) {
|
||||
@ -424,7 +429,7 @@ func CmdAuth(c *cli.Context) error {
|
||||
} else {
|
||||
log.Info(c, "Logging in...")
|
||||
}
|
||||
err = api.DoLogIn(c, username, string(pass))
|
||||
err = api.DoLogIn(c, username, pass)
|
||||
if err != nil {
|
||||
return cli.NewExitError(fmt.Sprintf("error logging in: %v", err), 1)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user