Fix issues with the conn after login errors

merge-requests/3/head
meskio 5 years ago
parent edc825eafe
commit 5822bf0965
Signed by: meskio
GPG Key ID: 52B8F5AC97A2DA86
  1. 7
      ldap/user.go

@ -10,17 +10,19 @@ import (
// ValidateUser in the ldap
func (l *Ldap) ValidateUser(user string, pass string) error {
conn, err := l.login(user, pass)
defer conn.Close()
if err == nil {
conn.Close()
}
return err
}
// ChangePass changes logged in user's password
func (l *Ldap) ChangePass(user string, oldpass string, newpass string) error {
conn, err := l.login(user, oldpass)
defer conn.Close()
if err != nil {
return err
}
defer conn.Close()
passwordModifyRequest := ldap.NewPasswordModifyRequest("", oldpass, newpass)
_, err = conn.PasswordModify(passwordModifyRequest)
@ -34,6 +36,7 @@ func (l *Ldap) login(user string, password string) (*ldap.Conn, error) {
}
entry, err := l.searchUser(user, conn)
if err != nil {
conn.Close()
return nil, err
}
userdn := entry.DN

Loading…
Cancel
Save