mirror of
https://github.com/zitadel/zitadel.git
synced 2025-12-07 16:22:06 +00:00
fix: add preferred login name of editor to changes (#1847)
* fix: add preferred login name of editor to changes * proto linting
This commit is contained in:
@@ -3,36 +3,33 @@ package eventstore
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"github.com/caos/zitadel/internal/domain"
|
||||
"github.com/caos/zitadel/internal/eventstore/v1"
|
||||
"github.com/caos/zitadel/internal/eventstore/v1/models"
|
||||
iam_view "github.com/caos/zitadel/internal/iam/repository/view"
|
||||
org_view "github.com/caos/zitadel/internal/org/repository/view"
|
||||
usr_model "github.com/caos/zitadel/internal/user/model"
|
||||
"github.com/caos/zitadel/internal/user/repository/view"
|
||||
"github.com/golang/protobuf/ptypes"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/caos/logging"
|
||||
"github.com/golang/protobuf/ptypes"
|
||||
|
||||
"github.com/caos/zitadel/internal/api/authz"
|
||||
"github.com/caos/zitadel/internal/config/systemdefaults"
|
||||
"github.com/caos/zitadel/internal/domain"
|
||||
"github.com/caos/zitadel/internal/errors"
|
||||
"github.com/caos/zitadel/internal/eventstore/v1"
|
||||
"github.com/caos/zitadel/internal/eventstore/v1/models"
|
||||
iam_model "github.com/caos/zitadel/internal/iam/model"
|
||||
iam_view "github.com/caos/zitadel/internal/iam/repository/view"
|
||||
iam_es_model "github.com/caos/zitadel/internal/iam/repository/view/model"
|
||||
iam_view_model "github.com/caos/zitadel/internal/iam/repository/view/model"
|
||||
mgmt_view "github.com/caos/zitadel/internal/management/repository/eventsourcing/view"
|
||||
org_model "github.com/caos/zitadel/internal/org/model"
|
||||
org_es_model "github.com/caos/zitadel/internal/org/repository/eventsourcing/model"
|
||||
org_view "github.com/caos/zitadel/internal/org/repository/view"
|
||||
"github.com/caos/zitadel/internal/org/repository/view/model"
|
||||
"github.com/caos/zitadel/internal/telemetry/tracing"
|
||||
usr_model "github.com/caos/zitadel/internal/user/model"
|
||||
"github.com/caos/zitadel/internal/user/repository/view"
|
||||
usr_es_model "github.com/caos/zitadel/internal/user/repository/view/model"
|
||||
)
|
||||
|
||||
const (
|
||||
orgOwnerRole = "ORG_OWNER"
|
||||
)
|
||||
|
||||
type OrgRepository struct {
|
||||
SearchLimit uint64
|
||||
Eventstore v1.Eventstore
|
||||
@@ -104,10 +101,12 @@ func (repo *OrgRepository) OrgChanges(ctx context.Context, id string, lastSequen
|
||||
}
|
||||
for _, change := range changes.Changes {
|
||||
change.ModifierName = change.ModifierId
|
||||
change.ModifierLoginName = change.ModifierId
|
||||
user, _ := repo.userByID(ctx, change.ModifierId)
|
||||
if user != nil {
|
||||
change.ModifierLoginName = user.PreferredLoginName
|
||||
if user.HumanView != nil {
|
||||
change.ModifierName = user.DisplayName
|
||||
change.ModifierName = user.HumanView.DisplayName
|
||||
}
|
||||
if user.MachineView != nil {
|
||||
change.ModifierName = user.MachineView.Name
|
||||
|
||||
@@ -7,6 +7,8 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/caos/logging"
|
||||
"github.com/golang/protobuf/ptypes"
|
||||
|
||||
"github.com/caos/zitadel/internal/api/authz"
|
||||
"github.com/caos/zitadel/internal/domain"
|
||||
caos_errs "github.com/caos/zitadel/internal/errors"
|
||||
@@ -25,7 +27,6 @@ import (
|
||||
usr_model "github.com/caos/zitadel/internal/user/model"
|
||||
usr_view "github.com/caos/zitadel/internal/user/repository/view"
|
||||
usr_es_model "github.com/caos/zitadel/internal/user/repository/view/model"
|
||||
"github.com/golang/protobuf/ptypes"
|
||||
)
|
||||
|
||||
type ProjectRepo struct {
|
||||
@@ -195,10 +196,12 @@ func (repo *ProjectRepo) ProjectChanges(ctx context.Context, id string, lastSequ
|
||||
}
|
||||
for _, change := range changes.Changes {
|
||||
change.ModifierName = change.ModifierId
|
||||
change.ModifierLoginName = change.ModifierId
|
||||
user, _ := repo.userByID(ctx, change.ModifierId)
|
||||
if user != nil {
|
||||
change.ModifierLoginName = user.PreferredLoginName
|
||||
if user.HumanView != nil {
|
||||
change.ModifierName = user.DisplayName
|
||||
change.ModifierName = user.HumanView.DisplayName
|
||||
}
|
||||
if user.MachineView != nil {
|
||||
change.ModifierName = user.MachineView.Name
|
||||
@@ -272,10 +275,12 @@ func (repo *ProjectRepo) ApplicationChanges(ctx context.Context, projectID strin
|
||||
}
|
||||
for _, change := range changes.Changes {
|
||||
change.ModifierName = change.ModifierId
|
||||
change.ModifierLoginName = change.ModifierId
|
||||
user, _ := repo.userByID(ctx, change.ModifierId)
|
||||
if user != nil {
|
||||
change.ModifierLoginName = user.PreferredLoginName
|
||||
if user.HumanView != nil {
|
||||
change.ModifierName = user.DisplayName
|
||||
change.ModifierName = user.HumanView.DisplayName
|
||||
}
|
||||
if user.MachineView != nil {
|
||||
change.ModifierName = user.MachineView.Name
|
||||
|
||||
@@ -98,8 +98,10 @@ func (repo *UserRepo) UserChanges(ctx context.Context, id string, lastSequence u
|
||||
}
|
||||
for _, change := range changes.Changes {
|
||||
change.ModifierName = change.ModifierID
|
||||
change.ModifierLoginName = change.ModifierID
|
||||
user, _ := repo.UserByID(ctx, change.ModifierID)
|
||||
if user != nil {
|
||||
change.ModifierLoginName = user.PreferredLoginName
|
||||
if user.HumanView != nil {
|
||||
change.ModifierName = user.HumanView.DisplayName
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user