Fixed Change Password Bug

This commit is contained in:
Chris Mann 2023-07-25 08:46:12 +02:00
parent 947d0328b7
commit 1e44165fad
2 changed files with 5 additions and 3 deletions

View file

@ -96,17 +96,17 @@ func handleLostPassword(w http.ResponseWriter, r *http.Request) {
}
ldapConn, err := openNewUserLdap(config)
if err != nil {
log.Printf(fmt.Sprintf("handleLostPassword : %v %v", err, ldapConn))
log.Printf(fmt.Sprintf("handleLostPassword 99 : %v %v", err, ldapConn))
data.ErrorMessage = err.Error()
}
err = passwordLost(user, config, ldapConn)
if err != nil {
log.Printf(fmt.Sprintf("handleLostPassword : %v %v", err, ldapConn))
log.Printf(fmt.Sprintf("handleLostPassword 104 : %v %v", err, ldapConn))
data.ErrorMessage = err.Error()
} else {
err = ldapConn.Bind(config.NewUserDN, config.NewUserPassword)
if err != nil {
log.Printf(fmt.Sprintf("handleLostPassword : %v %v", err, ldapConn))
log.Printf(fmt.Sprintf("handleLostPassword 109 : %v %v", err, ldapConn))
data.ErrorMessage = err.Error()
} else {
data.Success = true

View file

@ -159,6 +159,8 @@ func modify(user User, config *ConfigFile, ldapConn *ldap.Conn) error {
func passwd(user User, config *ConfigFile, ldapConn *ldap.Conn) error {
passwordModifyRequest := ldap.NewPasswordModifyRequest(user.DN, "", user.Password)
_, err := ldapConn.PasswordModify(passwordModifyRequest)
log.Printf(fmt.Sprintf("passwd 162 : %v %v", err, ldapConn))
log.Printf(fmt.Sprintf("passwd 163 : %v", user))
return err
}