Password correction on creation

This commit is contained in:
Chris Mann 2023-07-21 22:48:46 +02:00
parent 7131b81c7b
commit beea53a14e
2 changed files with 19 additions and 2 deletions

View file

@ -38,6 +38,9 @@
<p>Vous pouvez <strong><a href="/invite/new_account">démarrer la création de votre compte ici</a></strong> !</p>
<hr class="mt-4" />
<p>Mot de passe oublié ?
Écrivez à <samp>chris</samp><img src="static/image/at_sign.svg" style="height: 1em" alt="arobase" /><samp>lesgandsvoisins.com</samp>.</p>

View file

@ -75,8 +75,12 @@ func addNewUser(newUser NewUser, config *ConfigFile, ldapConn *ldap.Conn) bool {
req.Attribute("description", []string{newUser.Description})
}
if newUser.Password != "" {
pw, _ := SSHAEncode(newUser.Password)
req.Attribute("userPassword", []string{pw})
pwdEncoded, _ := encodePassword(newUser.Password)
// if err != nil {
// log.Printf("Error encoding password: %s", err)
// return err
// }
req.Attribute("userPassword", []string{pwdEncoded})
}
// conn :=
@ -92,3 +96,13 @@ func addNewUser(newUser NewUser, config *ConfigFile, ldapConn *ldap.Conn) bool {
return true
}
}
function encodePassword (inPassword string) (string, error) {
utf16 := unicode.UTF16(unicode.LittleEndian, unicode.IgnoreBOM)
return utf16.NewEncoder().String("\"" + password + "\"")
// if err != nil {
// log.Printf("Error encoding password: %s", err)
// return err
// }
}