fix: commandside queries (#1313)

* fix: move user by id to query side

* fix: move get passwordless to query side

# Conflicts:
#	internal/user/repository/eventsourcing/eventstore.go

* fix: move get passwordless to query side

* remove user eventstore

* remove unused models

* org changes

* org changes

* fix: move org queries to query side

* fix: remove org eventstore

* fix: remove org eventstore

* fix: remove org eventstore

* remove project from es v1

* project cleanup

* project cleanup

* fix: remove org eventstore

* fix: remove iam eventstore

Co-authored-by: Livio Amstutz <livio.a@gmail.com>
This commit is contained in:
Fabi
2021-02-22 14:08:47 +01:00
committed by GitHub
parent 2ba56595b1
commit 428ef4acdb
106 changed files with 2301 additions and 2799 deletions

View File

@@ -4,21 +4,22 @@ import (
"context"
"time"
"github.com/caos/zitadel/internal/eventstore"
"github.com/caos/zitadel/internal/eventstore/models"
usr_view "github.com/caos/zitadel/internal/user/repository/view"
"github.com/caos/logging"
"github.com/caos/zitadel/internal/auth/repository/eventsourcing/view"
"github.com/caos/zitadel/internal/errors"
proj_event "github.com/caos/zitadel/internal/project/repository/eventsourcing"
"github.com/caos/zitadel/internal/telemetry/tracing"
usr_model "github.com/caos/zitadel/internal/user/model"
user_event "github.com/caos/zitadel/internal/user/repository/eventsourcing"
"github.com/caos/zitadel/internal/user/repository/view/model"
)
type TokenRepo struct {
UserEvents *user_event.UserEventstore
ProjectEvents *proj_event.ProjectEventstore
View *view.View
Eventstore eventstore.Eventstore
View *view.View
}
func (repo *TokenRepo) IsTokenValid(ctx context.Context, userID, tokenID string) (bool, error) {
@@ -43,7 +44,7 @@ func (repo *TokenRepo) TokenByID(ctx context.Context, userID, tokenID string) (*
token.UserID = userID
}
events, esErr := repo.UserEvents.UserEventsByID(ctx, userID, token.Sequence)
events, esErr := repo.getUserEvents(ctx, userID, token.Sequence)
if errors.IsNotFound(viewErr) && len(events) == 0 {
return nil, errors.ThrowNotFound(nil, "EVENT-4T90g", "Errors.Token.NotFound")
}
@@ -65,11 +66,10 @@ func (repo *TokenRepo) TokenByID(ctx context.Context, userID, tokenID string) (*
return model.TokenViewToModel(token), nil
}
func AppendAudIfNotExisting(aud string, existingAud []string) []string {
for _, a := range existingAud {
if a == aud {
return existingAud
}
func (r *TokenRepo) getUserEvents(ctx context.Context, userID string, sequence uint64) ([]*models.Event, error) {
query, err := usr_view.UserByIDQuery(userID, sequence)
if err != nil {
return nil, err
}
return append(existingAud, aud)
return r.Eventstore.FilterEvents(ctx, query)
}