Handle multiple mail values
This commit is contained in:
parent
b3cc2ecd45
commit
c28c25496d
2 changed files with 6 additions and 15 deletions
|
@ -21,14 +21,16 @@
|
||||||
|
|
||||||
<div class="form-row">
|
<div class="form-row">
|
||||||
<div class="form-group col-md-12">
|
<div class="form-group col-md-12">
|
||||||
<form method="POST" class="mt-4" enctype="multipart/form-data" action="/user/mail">
|
|
||||||
{{range $index, $email := .Data.MailValues }}
|
{{range $index, $email := .Data.MailValues }}
|
||||||
|
<form method="POST" class="mt-4" enctype="multipart/form-data" action="/user/mail">
|
||||||
<input type="email" name="email" value="{{$email}}" required>
|
<input type="email" name="email" value="{{$email}}" required>
|
||||||
<input type="submit" name="delete" value="Delete">
|
<input type="submit" name="delete" value="Delete">
|
||||||
<input type="hidden" name="action" value="delete">
|
<input type="hidden" name="action" value="Delete">
|
||||||
<input type="hidden" name="index" value="{{$index}}">
|
<input type="hidden" name="index" value="{{$index}}">
|
||||||
{{end}}
|
|
||||||
</form>
|
</form>
|
||||||
|
{{end}}
|
||||||
|
|
||||||
<br>
|
<br>
|
||||||
<form method="POST" class="mt-4" enctype="multipart/form-data" action="/user/mail">
|
<form method="POST" class="mt-4" enctype="multipart/form-data" action="/user/mail">
|
||||||
<input type="email" name="email" required>
|
<input type="email" name="email" required>
|
||||||
|
|
13
view-user.go
13
view-user.go
|
@ -30,7 +30,6 @@ func handleUserMail(w http.ResponseWriter, r *http.Request) {
|
||||||
}
|
}
|
||||||
email := r.FormValue("email")
|
email := r.FormValue("email")
|
||||||
action := r.FormValue("add")
|
action := r.FormValue("add")
|
||||||
index := r.FormValue("index")
|
|
||||||
var err error
|
var err error
|
||||||
if action == "Add" {
|
if action == "Add" {
|
||||||
// Add the new mail value to the entry
|
// 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)
|
http.Error(w, fmt.Sprintf("Error adding the email: %v", modifyRequest), http.StatusInternalServerError)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
} else if action == "Delete" && index != "" {
|
} else if action == "Delete" {
|
||||||
// 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]
|
|
||||||
}
|
|
||||||
|
|
||||||
modifyRequest := ldap.NewModifyRequest(login.Info.DN, nil)
|
modifyRequest := ldap.NewModifyRequest(login.Info.DN, nil)
|
||||||
modifyRequest.Delete("mail", []string{email})
|
modifyRequest.Delete("mail", []string{email})
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue