Fix duplicated user in ldap

This commit is contained in:
jiafeng zheng 2021-06-16 16:17:01 +08:00
parent 813205af9a
commit c2d4161bce

View file

@ -105,7 +105,7 @@ func (t *LoginTypePassword) Login(ctx context.Context, req interface{}) (*Login,
JSON: jsonerror.InvalidUsername(err.Error()), JSON: jsonerror.InvalidUsername(err.Error()),
} }
} }
if len(sr.Entries) >= 1 { if len(sr.Entries) > 1 {
return nil, &util.JSONResponse{ return nil, &util.JSONResponse{
Code: http.StatusUnauthorized, Code: http.StatusUnauthorized,
JSON: jsonerror.BadJSON("'user' must be duplicated."), JSON: jsonerror.BadJSON("'user' must be duplicated."),
@ -134,7 +134,6 @@ func (t *LoginTypePassword) Login(ctx context.Context, req interface{}) (*Login,
_, err = t.GetAccountByLocalpart(ctx, localpart) _, err = t.GetAccountByLocalpart(ctx, localpart)
if err != nil { if err != nil {
if err == sql.ErrNoRows { if err == sql.ErrNoRows {
util.GetLogger(ctx).Debugf("registing user, %+v %+v", localpart, r.Password)
var accRes api.PerformAccountCreationResponse var accRes api.PerformAccountCreationResponse
err = t.UserAPI.PerformAccountCreation(ctx, &api.PerformAccountCreationRequest{ err = t.UserAPI.PerformAccountCreation(ctx, &api.PerformAccountCreationRequest{
AppServiceID: "", AppServiceID: "",