Some fixups around error/warning in LDAP

This commit is contained in:
Jeff Mitchell 2016-04-02 13:33:00 -04:00
parent 3e5fe09dd0
commit f5f9c098b7

View File

@ -180,7 +180,7 @@ func (b *backend) Login(req *logical.Request, username string, password string)
allgroups = append(allgroups, gname) allgroups = append(allgroups, gname)
} }
} else { } else {
resp.AddWarning("No group DN configured; only policies from locally-defined groups added") resp.AddWarning("no group DN configured; only policies from locally-defined groups available")
} }
for _, gname := range allgroups { for _, gname := range allgroups {
@ -191,7 +191,12 @@ func (b *backend) Login(req *logical.Request, username string, password string)
} }
if len(policies) == 0 { if len(policies) == 0 {
resp.Data["error"] = "user is not a member of any authorized group" errStr := "user is not a member of any authorized group"
if len(resp.Warnings()) > 0 {
errStr = fmt.Sprintf("%s; additionally, %s", errStr, resp.Warnings()[0])
}
resp.Data["error"] = errStr
return nil, resp, nil return nil, resp, nil
} }