This commit is contained in:
Chris Mann 2023-07-23 16:34:51 +02:00
parent 64ab2160fa
commit eb6410fa08
2 changed files with 9 additions and 4 deletions

View file

@ -34,7 +34,7 @@ func passwordLost(user User, config *ConfigFile, ldapConn *ldap.Conn) error {
}
searchFilter := "(|"
if user.CN != "" {
searchFilter += "(cn=" + user.CN + ")"
searchFilter += "(cn=" + user.UID + ")"
}
if user.Mail != "" {
searchFilter += "(mail=" + user.Mail + ")"
@ -57,6 +57,10 @@ func passwordLost(user User, config *ConfigFile, ldapConn *ldap.Conn) error {
}
log.Printf(fmt.Sprintf("passwordLost : %v", user))
log.Printf(fmt.Sprintf("passwordLost : %v", searchRes.Entries[0]))
log.Printf(fmt.Sprintf("passwordLost : %v", searchRes.Entries[0].GetAttributeValue("cn")))
log.Printf(fmt.Sprintf("passwordLost : %v", searchRes.Entries[0].GetAttributeValue("uid")))
log.Printf(fmt.Sprintf("passwordLost : %v", searchRes.Entries[0].GetAttributeValue("mail")))
log.Printf(fmt.Sprintf("passwordLost : %v", searchRes.Entries[0].GetAttributeValue("carLicense")))
// Préparation du courriel à envoyer
user.Password = suggestPassword()
code := b64.URLEncoding.EncodeToString([]byte(user.UID + ";" + user.Password))

View file

@ -82,9 +82,10 @@ func handleLostPassword(w http.ResponseWriter, r *http.Request) {
data.Mail = strings.TrimSpace(strings.Join(r.Form["mail"], ""))
data.OtherMailbox = strings.TrimSpace(strings.Join(r.Form["othermailbox"], ""))
user := User{
CN: data.Username,
Mail: data.Mail,
OtherMailbox: data.OtherMailbox,
CN: strings.TrimSpace(strings.Join(r.Form["username"], "")),
UID: strings.TrimSpace(strings.Join(r.Form["username"], "")),
Mail: strings.TrimSpace(strings.Join(r.Form["mail"], "")),
OtherMailbox: strings.TrimSpace(strings.Join(r.Form["othermailbox"], "")),
}
ldapConn, err := openNewUserLdap(config)
if err != nil {