Skip to content

Commit

Permalink
Removed \ and “ from the possible symbols that the password generator…
Browse files Browse the repository at this point in the history
… can use
  • Loading branch information
Ilyes512 committed Jul 27, 2018
1 parent 81b975d commit 8506e40
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion pkg/template/functions.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ import (
)

var (
// custom symbols: removed \ and "
customSymbols = "~!@#$%^&*()_+`-={}|[]:<>?,./"

// FuncMap contains the functions exposed to templating engine.
FuncMap = template.FuncMap{
// TODO confirmation prompt
Expand Down Expand Up @@ -90,7 +93,13 @@ var (

// password.Generate(length, numDigits, numSymbols int, noUpper, allowRepeat bool) (string, error)
"password": func(length, numDigits, numSymbols int, noUpper, allowRepeat bool) string {
res, err := password.Generate(length, numDigits, numSymbols, noUpper, allowRepeat)
generator, err := password.NewGenerator(&password.GeneratorInput{Symbols: customSymbols})

if err != nil {
return fmt.Sprintf("failed to generate password generator", err)
}

res, err := generator.Generate(length, numDigits, numSymbols, noUpper, allowRepeat)
if err != nil {
return fmt.Sprintf("failed to generate password: %s", err)
}
Expand Down

0 comments on commit 8506e40

Please sign in to comment.