do not return error when ldap bind failed

This commit is contained in:
Tan Jiang 2017-04-26 14:05:06 +08:00
parent ee93627391
commit 2f6dd6f102
2 changed files with 8 additions and 4 deletions

View File

@ -79,7 +79,8 @@ func (l *Auth) Authenticate(m models.AuthModel) (*models.User, error) {
log.Debugf("username: %s, dn: %s", u.Username, dn)
if err := ldapUtils.Bind(ldapConfs, dn, m.Password); err != nil {
return nil, fmt.Errorf("Failed to bind user, username: %s, dn: %s, error: %v", u.Username, dn, err)
log.Warningf("Failed to bind user, username: %s, dn: %s, error: %v", u.Username, dn, err)
return nil, nil
}
exist, err := dao.UserExists(u, "username")
if err != nil {

View File

@ -124,8 +124,11 @@ func TestAuthenticate(t *testing.T) {
}
person.Principal = "test"
person.Password = "1"
_, err = auth.Authenticate(person)
if err == nil {
t.Errorf("Expected error for wrong password")
user, err = auth.Authenticate(person)
if err != nil {
t.Errorf("unexpected ldap error: %v", err)
}
if user != nil {
t.Errorf("Nil user expected for wrong password")
}
}