Refactoring
This commit is contained in:
parent
7f3383944b
commit
3cee5a3745
2 changed files with 11 additions and 8 deletions
|
@ -46,9 +46,10 @@ func passwordLost(user User, config *ConfigFile, ldapConn *ldap.Conn) error {
|
||||||
searchReq := ldap.NewSearchRequest(config.UserBaseDN, ldap.ScopeSingleLevel, ldap.NeverDerefAliases, 0, 0, false, searchFilter, []string{"cn", "uid", "mail", "carLicense", "sn", "displayName", "givenName"}, nil)
|
searchReq := ldap.NewSearchRequest(config.UserBaseDN, ldap.ScopeSingleLevel, ldap.NeverDerefAliases, 0, 0, false, searchFilter, []string{"cn", "uid", "mail", "carLicense", "sn", "displayName", "givenName"}, nil)
|
||||||
searchRes, err := ldapConn.Search(searchReq)
|
searchRes, err := ldapConn.Search(searchReq)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf(fmt.Sprintf("passwordLost 49 : %v %v", err, ldapConn))
|
log.Printf(fmt.Sprintf("passwordLost search : %v %v", err, ldapConn))
|
||||||
log.Printf(fmt.Sprintf("passwordLost 50 : %v", searchReq))
|
log.Printf(fmt.Sprintf("passwordLost search : %v", searchReq))
|
||||||
log.Printf(fmt.Sprintf("passwordLost 51: %v", user))
|
log.Printf(fmt.Sprintf("passwordLost search : %v", searchRes))
|
||||||
|
log.Printf(fmt.Sprintf("passwordLost search: %v", user))
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if len(searchRes.Entries) == 0 {
|
if len(searchRes.Entries) == 0 {
|
||||||
|
|
|
@ -7,6 +7,7 @@ import (
|
||||||
"net/http"
|
"net/http"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/go-ldap/ldap/v3"
|
||||||
"github.com/gorilla/mux"
|
"github.com/gorilla/mux"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -33,23 +34,24 @@ func handleLostPassword(w http.ResponseWriter, r *http.Request) {
|
||||||
Mail: strings.TrimSpace(strings.Join(r.Form["mail"], "")),
|
Mail: strings.TrimSpace(strings.Join(r.Form["mail"], "")),
|
||||||
OtherMailbox: strings.TrimSpace(strings.Join(r.Form["othermailbox"], "")),
|
OtherMailbox: strings.TrimSpace(strings.Join(r.Form["othermailbox"], "")),
|
||||||
}
|
}
|
||||||
ldapConn, err := openNewUserLdap(config)
|
ldapNewConn, err := openNewUserLdap(config)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf(fmt.Sprintf("handleLostPassword 99 : %v %v", err, ldapConn))
|
log.Printf(fmt.Sprintf("handleLostPassword 99 : %v %v", err, ldapNewConn))
|
||||||
data.Common.ErrorMessage = err.Error()
|
data.Common.ErrorMessage = err.Error()
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf(fmt.Sprintf("handleLostPassword 104 : %v %v", err, ldapConn))
|
log.Printf(fmt.Sprintf("handleLostPassword 104 : %v %v", err, ldapNewConn))
|
||||||
data.Common.ErrorMessage = err.Error()
|
data.Common.ErrorMessage = err.Error()
|
||||||
} else {
|
} else {
|
||||||
err = ldapConn.Bind(config.NewUserDN, config.NewUserPassword)
|
// err = ldapConn.Bind(config.NewUserDN, config.NewUserPassword)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf(fmt.Sprintf("handleLostPassword 109 : %v %v", err, ldapConn))
|
log.Printf(fmt.Sprintf("handleLostPassword 109 : %v %v", err, ldapNewConn))
|
||||||
data.Common.ErrorMessage = err.Error()
|
data.Common.ErrorMessage = err.Error()
|
||||||
} else {
|
} else {
|
||||||
data.Common.Success = true
|
data.Common.Success = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
err = passwordLost(user, config, ldapNewConn)
|
||||||
}
|
}
|
||||||
data.Common.CanAdmin = false
|
data.Common.CanAdmin = false
|
||||||
templateLostPasswordPage.Execute(w, data)
|
templateLostPasswordPage.Execute(w, data)
|
||||||
|
|
Loading…
Reference in a new issue