mirror of
https://github.com/zitadel/zitadel.git
synced 2025-08-12 11:37:32 +00:00
fix(changes): decide if human or machine modifier (#953)
This commit is contained in:
@@ -394,8 +394,13 @@ func (repo *UserRepo) MyUserChanges(ctx context.Context, lastSequence uint64, li
|
|||||||
change.ModifierName = change.ModifierID
|
change.ModifierName = change.ModifierID
|
||||||
user, _ := repo.UserEvents.UserByID(ctx, change.ModifierID)
|
user, _ := repo.UserEvents.UserByID(ctx, change.ModifierID)
|
||||||
if user != nil {
|
if user != nil {
|
||||||
|
if user.Human != nil {
|
||||||
change.ModifierName = user.DisplayName
|
change.ModifierName = user.DisplayName
|
||||||
}
|
}
|
||||||
|
if user.Machine != nil {
|
||||||
|
change.ModifierName = user.Machine.Name
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return changes, nil
|
return changes, nil
|
||||||
}
|
}
|
||||||
|
@@ -2,9 +2,10 @@ package eventstore
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
iam_es "github.com/caos/zitadel/internal/iam/repository/eventsourcing"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
iam_es "github.com/caos/zitadel/internal/iam/repository/eventsourcing"
|
||||||
|
|
||||||
"github.com/caos/logging"
|
"github.com/caos/logging"
|
||||||
"github.com/caos/zitadel/internal/api/authz"
|
"github.com/caos/zitadel/internal/api/authz"
|
||||||
"github.com/caos/zitadel/internal/config/systemdefaults"
|
"github.com/caos/zitadel/internal/config/systemdefaults"
|
||||||
@@ -166,8 +167,13 @@ func (repo *OrgRepository) OrgChanges(ctx context.Context, id string, lastSequen
|
|||||||
change.ModifierName = change.ModifierId
|
change.ModifierName = change.ModifierId
|
||||||
user, _ := repo.UserEvents.UserByID(ctx, change.ModifierId)
|
user, _ := repo.UserEvents.UserByID(ctx, change.ModifierId)
|
||||||
if user != nil {
|
if user != nil {
|
||||||
|
if user.Human != nil {
|
||||||
change.ModifierName = user.DisplayName
|
change.ModifierName = user.DisplayName
|
||||||
}
|
}
|
||||||
|
if user.Machine != nil {
|
||||||
|
change.ModifierName = user.Machine.Name
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return changes, nil
|
return changes, nil
|
||||||
}
|
}
|
||||||
|
@@ -299,8 +299,13 @@ func (repo *ProjectRepo) ProjectChanges(ctx context.Context, id string, lastSequ
|
|||||||
change.ModifierName = change.ModifierId
|
change.ModifierName = change.ModifierId
|
||||||
user, _ := repo.UserEvents.UserByID(ctx, change.ModifierId)
|
user, _ := repo.UserEvents.UserByID(ctx, change.ModifierId)
|
||||||
if user != nil {
|
if user != nil {
|
||||||
|
if user.Human != nil {
|
||||||
change.ModifierName = user.DisplayName
|
change.ModifierName = user.DisplayName
|
||||||
}
|
}
|
||||||
|
if user.Machine != nil {
|
||||||
|
change.ModifierName = user.Machine.Name
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return changes, nil
|
return changes, nil
|
||||||
}
|
}
|
||||||
@@ -389,8 +394,13 @@ func (repo *ProjectRepo) ApplicationChanges(ctx context.Context, id string, appI
|
|||||||
change.ModifierName = change.ModifierId
|
change.ModifierName = change.ModifierId
|
||||||
user, _ := repo.UserEvents.UserByID(ctx, change.ModifierId)
|
user, _ := repo.UserEvents.UserByID(ctx, change.ModifierId)
|
||||||
if user != nil {
|
if user != nil {
|
||||||
|
if user.Human != nil {
|
||||||
change.ModifierName = user.DisplayName
|
change.ModifierName = user.DisplayName
|
||||||
}
|
}
|
||||||
|
if user.Machine != nil {
|
||||||
|
change.ModifierName = user.Machine.Name
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return changes, nil
|
return changes, nil
|
||||||
}
|
}
|
||||||
|
@@ -2,6 +2,7 @@ package eventstore
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
es_int "github.com/caos/zitadel/internal/eventstore"
|
es_int "github.com/caos/zitadel/internal/eventstore"
|
||||||
es_models "github.com/caos/zitadel/internal/eventstore/models"
|
es_models "github.com/caos/zitadel/internal/eventstore/models"
|
||||||
es_sdk "github.com/caos/zitadel/internal/eventstore/sdk"
|
es_sdk "github.com/caos/zitadel/internal/eventstore/sdk"
|
||||||
@@ -184,8 +185,13 @@ func (repo *UserRepo) UserChanges(ctx context.Context, id string, lastSequence u
|
|||||||
change.ModifierName = change.ModifierID
|
change.ModifierName = change.ModifierID
|
||||||
user, _ := repo.UserEvents.UserByID(ctx, change.ModifierID)
|
user, _ := repo.UserEvents.UserByID(ctx, change.ModifierID)
|
||||||
if user != nil {
|
if user != nil {
|
||||||
|
if user.Human != nil {
|
||||||
change.ModifierName = user.DisplayName
|
change.ModifierName = user.DisplayName
|
||||||
}
|
}
|
||||||
|
if user.Machine != nil {
|
||||||
|
change.ModifierName = user.Machine.Name
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return changes, nil
|
return changes, nil
|
||||||
}
|
}
|
||||||
|
@@ -349,7 +349,7 @@ func (es *UserEventstore) RemoveUser(ctx context.Context, id string, orgIamPolic
|
|||||||
func (es *UserEventstore) UserChanges(ctx context.Context, id string, lastSequence uint64, limit uint64, sortAscending bool) (*usr_model.UserChanges, error) {
|
func (es *UserEventstore) UserChanges(ctx context.Context, id string, lastSequence uint64, limit uint64, sortAscending bool) (*usr_model.UserChanges, error) {
|
||||||
query := ChangesQuery(id, lastSequence, limit, sortAscending)
|
query := ChangesQuery(id, lastSequence, limit, sortAscending)
|
||||||
|
|
||||||
events, err := es.Eventstore.FilterEvents(context.Background(), query)
|
events, err := es.Eventstore.FilterEvents(ctx, query)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logging.Log("EVENT-g9HCv").WithError(err).Warn("eventstore unavailable")
|
logging.Log("EVENT-g9HCv").WithError(err).Warn("eventstore unavailable")
|
||||||
return nil, errors.ThrowInternal(err, "EVENT-htuG9", "Errors.Internal")
|
return nil, errors.ThrowInternal(err, "EVENT-htuG9", "Errors.Internal")
|
||||||
|
Reference in New Issue
Block a user