This commit is contained in:
adlerhurst
2020-11-25 20:04:32 +01:00
parent f6cdcee77a
commit 4bb9650f27
32 changed files with 1070 additions and 215 deletions
+2 -2
View File
@@ -5,7 +5,7 @@ import (
"github.com/caos/zitadel/internal/errors"
"github.com/caos/zitadel/internal/eventstore/v2"
"github.com/caos/zitadel/internal/eventstore/v2/repository"
es_repo "github.com/caos/zitadel/internal/eventstore/v2/repository"
)
const (
@@ -40,7 +40,7 @@ func NewAddedEvent(
}
}
func AddedEventMapper(event *repository.Event) (eventstore.EventReader, error) {
func AddedEventMapper(event *es_repo.Event) (eventstore.EventReader, error) {
e := &AddedEvent{
BaseEvent: *eventstore.BaseEventFromRepo(event),
}
@@ -19,8 +19,6 @@ type ChangedEvent struct {
Roles []string `json:"roles,omitempty"`
UserID string `json:"userId,omitempty"`
hasChanged bool
}
func (e *ChangedEvent) CheckPrevious() bool {
@@ -38,15 +36,16 @@ func ChangeEventFromExisting(
) (*ChangedEvent, error) {
change := NewChangedEvent(base, current.userID)
hasChanged := false
sort.Strings(current.Roles)
sort.Strings(roles)
if !reflect.DeepEqual(current.Roles, roles) {
change.Roles = roles
change.hasChanged = true
hasChanged = true
}
if !change.hasChanged {
if !hasChanged {
return nil, errors.ThrowPreconditionFailed(nil, "MEMBE-SeKlD", "Errors.NoChanges")
}