From c55d1c7bbe650bda96c5c5c1a91f02faa73049ed Mon Sep 17 00:00:00 2001 From: Chris Mann Date: Thu, 20 Jul 2023 17:52:16 +0200 Subject: [PATCH] Front-End Stuff --- invite.go | 3 +++ templates/invite_new_account.html | 1 + utils.go | 7 ++++++- 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/invite.go b/invite.go index 402fd50..d9e50e7 100644 --- a/invite.go +++ b/invite.go @@ -104,6 +104,7 @@ type NewAccountData struct { GivenName string Surname string Mail string + SuggestPW string ErrorUsernameTaken bool ErrorInvalidUsername bool @@ -147,6 +148,8 @@ func handleNewAccount(w http.ResponseWriter, r *http.Request, l *ldap.Conn, invi // tryCreateAccount(l, data, password1, password2, invitedBy) + } else { + data.SuggestPW = suggestPassword() } templateInviteNewAccount.Execute(w, data) diff --git a/templates/invite_new_account.html b/templates/invite_new_account.html index 48f39c1..85e100a 100644 --- a/templates/invite_new_account.html +++ b/templates/invite_new_account.html @@ -62,6 +62,7 @@ + Utiliser ce mot de passe : {{ .SuggestPW }}
diff --git a/utils.go b/utils.go index 08c8699..3b4ec6d 100644 --- a/utils.go +++ b/utils.go @@ -8,7 +8,7 @@ import ( // "bytes" // "crypto/rand" // "encoding/binary" - // "encoding/hex" + "encoding/hex" // "fmt" // "html/template" // "log" @@ -43,6 +43,11 @@ func openLdap(config ConfigFile) *ldap.Conn { } } +func suggestPassword() string { + random := make([]byte, 32) + return hex.EncodeToString(random[0:4]) +} + func addNewUser(newUser NewUser, config *ConfigFile, login *LoginStatus) bool { log.Printf(fmt.Sprint("Adding New User")) // l := openLdap(config)