From c28c25496dc9b0778022cb051c184ef642a1b3db Mon Sep 17 00:00:00 2001 From: Chris Mann Date: Thu, 27 Jul 2023 22:10:04 +0200 Subject: [PATCH] Handle multiple mail values --- templates/user.html | 8 +++++--- view-user.go | 13 +------------ 2 files changed, 6 insertions(+), 15 deletions(-) diff --git a/templates/user.html b/templates/user.html index 3104dda..e194324 100644 --- a/templates/user.html +++ b/templates/user.html @@ -21,14 +21,16 @@
-
+ {{range $index, $email := .Data.MailValues }} + - + - {{end}}
+ {{end}} +
diff --git a/view-user.go b/view-user.go index e4686ae..58d6930 100644 --- a/view-user.go +++ b/view-user.go @@ -30,7 +30,6 @@ func handleUserMail(w http.ResponseWriter, r *http.Request) { } email := r.FormValue("email") action := r.FormValue("add") - index := r.FormValue("index") var err error if action == "Add" { // Add the new mail value to the entry @@ -42,17 +41,7 @@ func handleUserMail(w http.ResponseWriter, r *http.Request) { http.Error(w, fmt.Sprintf("Error adding the email: %v", modifyRequest), http.StatusInternalServerError) return } - } else if action == "Delete" && index != "" { - // Delete the specified mail value from the entry - i := strings.Index(index, ":") - if i > 0 { - index = index[:i] - } - i = strings.Index(index, "/") - if i > 0 { - index = index[:i] - } - + } else if action == "Delete" { modifyRequest := ldap.NewModifyRequest(login.Info.DN, nil) modifyRequest.Delete("mail", []string{email})