Skip to content

Commit

Permalink
Mask password when required + remove reset link cmd
Browse files Browse the repository at this point in the history
  • Loading branch information
mcorbin committed Jan 14, 2024
1 parent d8f0a1e commit 008cd1c
Show file tree
Hide file tree
Showing 382 changed files with 216,564 additions and 56 deletions.
9 changes: 0 additions & 9 deletions client/account.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,3 @@ func (c *Client) ChangeAccountPassword(ctx context.Context, payload apitypes.Cha
}
return result, nil
}

func (c *Client) AskResetPasswordLink(ctx context.Context, payload apitypes.ResetAccountPasswordLinkInput) (apitypes.Response, error) {
var result apitypes.Response
_, err := c.sendRequest(ctx, "/account/password/ask-reset", http.MethodPost, payload, &result, nil, NoAuth)
if err != nil {
return apitypes.Response{}, err
}
return result, nil
}
41 changes: 8 additions & 33 deletions cmd/account.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,43 +7,15 @@ import (
"fmt"
"os"
"strings"
"syscall"

"github.com/appclacks/cli/client"
apitypes "github.com/appclacks/go-types"
"github.com/cheynewallace/tabby"
"github.com/spf13/cobra"
"golang.org/x/term"
)

func sendResetPasswordLink() *cobra.Command {
var email string
var askResetPassword = &cobra.Command{
Use: "send-reset-link",
Short: "Send a reset password link for this email",
Run: func(cmd *cobra.Command, args []string) {
client := buildClient()
ctx, cancel := context.WithTimeout(context.Background(), defaultTimeout)
defer cancel()
payload := apitypes.ResetAccountPasswordLinkInput{
Email: email,
}
result, err := client.AskResetPasswordLink(ctx, payload)
exitIfError(err)
t := tabby.New()
t.AddHeader("Messages")
for _, message := range result.Messages {
t.AddLine(message)
}
t.Print()
os.Exit(0)
},
}
askResetPassword.PersistentFlags().StringVar(&email, "email", "", "Email")
err := askResetPassword.MarkPersistentFlagRequired("email")
exitIfError(err)
return askResetPassword

}

func changePasswordCmd() *cobra.Command {
var changePassword = &cobra.Command{
Use: "change",
Expand All @@ -55,12 +27,15 @@ func changePasswordCmd() *cobra.Command {
exitIfError(err)
email = strings.TrimSpace(email)
fmt.Printf("\n* Appclacks current Password:\n> ")
password, err := reader.ReadString('\n')
fmt.Println("")
bytePassword, err := term.ReadPassword(int(syscall.Stdin))
exitIfError(err)
password := string(bytePassword)
fmt.Println("")
password = strings.TrimSpace(password)
fmt.Printf("\n* Appclacks new Password:\n> ")
newPassword, err := reader.ReadString('\n')
byteNewPassword, err := term.ReadPassword(int(syscall.Stdin))
exitIfError(err)
newPassword := string(byteNewPassword)
fmt.Println("")
exitIfError(err)
newPassword = strings.TrimSpace(newPassword)
Expand Down
8 changes: 5 additions & 3 deletions cmd/login.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ import (
"fmt"
"os"
"strings"
"syscall"

"golang.org/x/term"
"gopkg.in/yaml.v3"

"github.com/appclacks/cli/client"
Expand Down Expand Up @@ -44,10 +46,10 @@ func loginCmd() *cobra.Command {
exitIfError(err)
email = strings.TrimSpace(email)
fmt.Printf("\n* Appclacks Password:\n> ")
password, err := reader.ReadString('\n')
fmt.Println("")
bytePassword, err := term.ReadPassword(int(syscall.Stdin))
exitIfError(err)
password = strings.TrimSpace(password)
fmt.Println("")
password := strings.TrimSpace(string(bytePassword))

cliClient, err := client.New(appclacksURL, client.WithUserPassword(client.AccountEmail(email), client.AccountPassword(password)))
exitIfError(err)
Expand Down
1 change: 0 additions & 1 deletion cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ func Execute() error {
Short: "Manage your account password",
}
password.AddCommand(changePasswordCmd())
password.AddCommand(sendResetPasswordLink())
account.AddCommand(password)

// token
Expand Down
2 changes: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@ require (
github.com/appclacks/go-types v0.0.0-20231220132907-2cf47ed6a994
github.com/cheynewallace/tabby v1.1.1
github.com/spf13/cobra v1.8.0
golang.org/x/term v0.16.0
gopkg.in/yaml.v3 v3.0.1
)

require (
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
golang.org/x/sys v0.16.0 // indirect
)
14 changes: 4 additions & 10 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,26 +1,20 @@
github.com/appclacks/go-types v0.0.0-20230701132920-beebbdd4d0ee h1:fqC3uBkZc33S3XAxHmZzcUfmzoGR3GLalryD8YJq4Qw=
github.com/appclacks/go-types v0.0.0-20230701132920-beebbdd4d0ee/go.mod h1:ULkbKlyVigBCY+eSEV0scorq+akwJlVbdnLI5xI8IwU=
github.com/appclacks/go-types v0.0.0-20230708134250-a6fdc4eb088f h1:U8QF08PPWcJXV0qBVDGcu/MKKvNSdy62fTpLsdhE8YM=
github.com/appclacks/go-types v0.0.0-20230708134250-a6fdc4eb088f/go.mod h1:ULkbKlyVigBCY+eSEV0scorq+akwJlVbdnLI5xI8IwU=
github.com/appclacks/go-types v0.0.0-20231220132907-2cf47ed6a994 h1:zxgTzkhrdTQ2jdzybr/+kZKOfjECBPHIznbZXBTItwc=
github.com/appclacks/go-types v0.0.0-20231220132907-2cf47ed6a994/go.mod h1:djYgTPlVCW/7sUcPRuqvJOoOKB/uforzYC2Bo2JBPK8=
github.com/cheynewallace/tabby v1.1.1 h1:JvUR8waht4Y0S3JF17G6Vhyt+FRhnqVCkk8l4YrOU54=
github.com/cheynewallace/tabby v1.1.1/go.mod h1:Pba/6cUL8uYqvOc9RkyvFbHGrQ9wShyrn6/S/1OYVys=
github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
github.com/cpuguy83/go-md2man/v2 v2.0.3/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM=
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/spf13/cobra v1.5.0 h1:X+jTBEBqF0bHN+9cSMgmfuvv2VHJ9ezmFNf9Y/XstYU=
github.com/spf13/cobra v1.5.0/go.mod h1:dWXEIy2H428czQCjInthrTRUg7yKbok+2Qi/yBIJoUM=
github.com/spf13/cobra v1.8.0 h1:7aJaZx1B85qltLMc546zn58BxxfZdR/W22ej9CFoEf0=
github.com/spf13/cobra v1.8.0/go.mod h1:WXLWApfZ71AjXPya3WOlMsY9yMs7YeiHhFVlvLyhcho=
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
golang.org/x/sys v0.16.0 h1:xWw16ngr6ZMtmxDyKyIgsE93KNKz5HKmMa3b8ALHidU=
golang.org/x/sys v0.16.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/term v0.16.0 h1:m+B6fahuftsE9qjo0VWp2FW0mB3MTJvR0BaMQrq0pmE=
golang.org/x/term v0.16.0/go.mod h1:yn7UURbUtPyrVJPGPq404EukNFxcm/foM+bV/bfcDsY=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
27 changes: 27 additions & 0 deletions vendor/golang.org/x/sys/LICENSE

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 22 additions & 0 deletions vendor/golang.org/x/sys/PATENTS

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions vendor/golang.org/x/sys/plan9/asm.s

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 30 additions & 0 deletions vendor/golang.org/x/sys/plan9/asm_plan9_386.s

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 30 additions & 0 deletions vendor/golang.org/x/sys/plan9/asm_plan9_amd64.s

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 25 additions & 0 deletions vendor/golang.org/x/sys/plan9/asm_plan9_arm.s

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

70 changes: 70 additions & 0 deletions vendor/golang.org/x/sys/plan9/const_plan9.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 008cd1c

Please sign in to comment.