changeset 511:b96b1b258cfa

Use already declared password length in reset password.
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Fri, 24 Aug 2018 16:26:53 +0200
parents e1466e65bc35
children 7474e9922ed5
files pkg/controllers/pwreset.go
diffstat 1 files changed, 4 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/pkg/controllers/pwreset.go	Fri Aug 24 16:20:21 2018 +0200
+++ b/pkg/controllers/pwreset.go	Fri Aug 24 16:26:53 2018 +0200
@@ -8,6 +8,7 @@
 	"log"
 	"net/http"
 	"os/exec"
+	"strconv"
 	"strings"
 	"text/template"
 	"time"
@@ -158,12 +159,13 @@
 
 func generateNewPassword() string {
 	// First try pwgen
-	out, err := exec.Command("pwgen", "-y", "20", "1").Output()
+	out, err := exec.Command(
+		"pwgen", "-y", strconv.Itoa(passwordLength), "1").Output()
 	if err == nil {
 		return strings.TrimSpace(string(out))
 	}
 	// Use internal generator.
-	return common.RandomString(20)
+	return common.RandomString(passwordLength)
 }
 
 func passwordResetRequest(