From e247d4b434b15eab278019276aeeccc910689a72 Mon Sep 17 00:00:00 2001 From: Chris Mann Date: Sat, 22 Jul 2023 09:49:09 +0200 Subject: [PATCH] Factoring the model user and correcting password --- model-user.go | 2 +- profile.go | 12 +++++++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/model-user.go b/model-user.go index 268915b..305fcd9 100644 --- a/model-user.go +++ b/model-user.go @@ -166,7 +166,7 @@ func replaceIfContent(modifReq *ldap.ModifyRequest, key string, value string, pr if value != "" { modifReq.Replace(key, []string{value}) } else { - modifReq.Delete(key, []string{value}) + modifReq.Delete(key, []string{previousValue}) } return nil } diff --git a/profile.go b/profile.go index 42a07bf..943d521 100644 --- a/profile.go +++ b/profile.go @@ -59,11 +59,13 @@ func handleProfile(w http.ResponseWriter, r *http.Request) { data.GivenName = user.GivenName data.Surname = user.SN data.Description = user.Description - err := modify(user, config, login.conn) - if err != nil { - data.ErrorMessage = "handleProfile : " + err.Error() - } else { - data.Success = true + if user.Mail != "" { + err := modify(user, config, login.conn) + if err != nil { + data.ErrorMessage = "handleProfile : " + err.Error() + } else { + data.Success = true + } } /*