From beea53a14e72764f6b55cd59c125b3d563ca7ed7 Mon Sep 17 00:00:00 2001 From: Chris Mann Date: Fri, 21 Jul 2023 22:48:46 +0200 Subject: [PATCH] Password correction on creation --- templates/login.html | 3 +++ utils.go | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/templates/login.html b/templates/login.html index 335656d..92d2597 100644 --- a/templates/login.html +++ b/templates/login.html @@ -38,6 +38,9 @@

Vous pouvez démarrer la création de votre compte ici !

+ +
+

Mot de passe oublié ? Écrivez à chrisarobaselesgandsvoisins.com.

diff --git a/utils.go b/utils.go index 6501663..4596f40 100644 --- a/utils.go +++ b/utils.go @@ -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 + // } + +} \ No newline at end of file