fix: uniqueness (#1710)

* fix: uniqueconstraint to lower

* feat: change org

* feat: org change test

* feat: change org

* fix: tests

* fix: handle domain claims correctly

* feat: update org

Co-authored-by: fabi <fabienne.gerschwiler@gmail.com>
This commit is contained in:
Livio Amstutz
2021-05-04 11:09:24 +02:00
committed by GitHub
parent 667cc30291
commit 87c1dfa3aa
28 changed files with 607 additions and 50 deletions

View File

@@ -0,0 +1,44 @@
package eventstore
import (
"context"
"github.com/caos/logging"
"github.com/caos/zitadel/internal/admin/repository/eventsourcing/view"
"github.com/caos/zitadel/internal/config/systemdefaults"
"github.com/caos/zitadel/internal/eventstore/v1"
"github.com/caos/zitadel/internal/user/model"
usr_view_model "github.com/caos/zitadel/internal/user/repository/view/model"
)
type UserRepo struct {
SearchLimit uint64
Eventstore v1.Eventstore
View *view.View
SystemDefaults systemdefaults.SystemDefaults
}
func (repo *UserRepo) Health(ctx context.Context) error {
return repo.Eventstore.Health(ctx)
}
func (repo *UserRepo) SearchUsers(ctx context.Context, request *model.UserSearchRequest) (*model.UserSearchResponse, error) {
sequence, sequenceErr := repo.View.GetLatestUserSequence()
logging.Log("EVENT-Gdbgfw").OnError(sequenceErr).Warn("could not read latest user sequence")
users, count, err := repo.View.SearchUsers(request)
if err != nil {
return nil, err
}
result := &model.UserSearchResponse{
Offset: request.Offset,
Limit: request.Limit,
TotalResult: count,
Result: usr_view_model.UsersToModel(users),
}
if sequenceErr == nil {
result.Sequence = sequence.CurrentSequence
result.Timestamp = sequence.LastSuccessfulSpoolerRun
}
return result, nil
}

View File

@@ -25,6 +25,7 @@ type EsRepository struct {
eventstore.IAMRepository
eventstore.AdministratorRepo
eventstore.FeaturesRepo
eventstore.UserRepo
}
func Start(ctx context.Context, conf Config, systemDefaults sd.SystemDefaults, roles []string) (*EsRepository, error) {
@@ -67,6 +68,12 @@ func Start(ctx context.Context, conf Config, systemDefaults sd.SystemDefaults, r
SearchLimit: conf.SearchLimit,
SystemDefaults: systemDefaults,
},
UserRepo: eventstore.UserRepo{
Eventstore: es,
View: view,
SearchLimit: conf.SearchLimit,
SystemDefaults: systemDefaults,
},
}, nil
}