mirror of
https://github.com/zitadel/zitadel.git
synced 2025-01-06 11:42:34 +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:
parent
59af02b2f3
commit
67462eefe0
@ -21,6 +21,7 @@ title: zitadel/change.proto
|
||||
| editor_id | string | - | |
|
||||
| editor_display_name | string | - | |
|
||||
| resource_owner_id | string | - | |
|
||||
| editor_preferred_login_name | string | - | |
|
||||
|
||||
|
||||
|
||||
|
@ -207,7 +207,7 @@ func RegisterRoutes(router *mux.Router, s {{.Name}}) {
|
||||
`
|
||||
|
||||
const docsTmpl = `---
|
||||
title: zitadel/admin.proto
|
||||
title: zitadel/assets
|
||||
---
|
||||
|
||||
## {{.Name}}
|
||||
|
@ -25,11 +25,12 @@ func UserChangesToPb(changes []*user_model.UserChange) []*change_pb.Change {
|
||||
|
||||
func UserChangeToPb(change *user_model.UserChange) *change_pb.Change {
|
||||
return &change_pb.Change{
|
||||
ChangeDate: change.ChangeDate,
|
||||
EventType: message.NewLocalizedEventType(change.EventType),
|
||||
Sequence: change.Sequence,
|
||||
EditorId: change.ModifierID,
|
||||
EditorDisplayName: change.ModifierName,
|
||||
ChangeDate: change.ChangeDate,
|
||||
EventType: message.NewLocalizedEventType(change.EventType),
|
||||
Sequence: change.Sequence,
|
||||
EditorId: change.ModifierID,
|
||||
EditorDisplayName: change.ModifierName,
|
||||
EditorPreferredLoginName: change.ModifierLoginName,
|
||||
// ResourceOwnerId: change.,TODO: resource owner not returned
|
||||
}
|
||||
}
|
||||
@ -44,11 +45,12 @@ func OrgChangesToPb(changes []*org_model.OrgChange) []*change_pb.Change {
|
||||
|
||||
func OrgChangeToPb(change *org_model.OrgChange) *change_pb.Change {
|
||||
return &change_pb.Change{
|
||||
ChangeDate: change.ChangeDate,
|
||||
EventType: message.NewLocalizedEventType(change.EventType),
|
||||
Sequence: change.Sequence,
|
||||
EditorId: change.ModifierId,
|
||||
EditorDisplayName: change.ModifierName,
|
||||
ChangeDate: change.ChangeDate,
|
||||
EventType: message.NewLocalizedEventType(change.EventType),
|
||||
Sequence: change.Sequence,
|
||||
EditorId: change.ModifierId,
|
||||
EditorDisplayName: change.ModifierName,
|
||||
EditorPreferredLoginName: change.ModifierLoginName,
|
||||
// ResourceOwnerId: change.,TODO: resource owner not returned
|
||||
}
|
||||
}
|
||||
@ -63,11 +65,12 @@ func ProjectChangesToPb(changes []*proj_model.ProjectChange) []*change_pb.Change
|
||||
|
||||
func ProjectChangeToPb(change *proj_model.ProjectChange) *change_pb.Change {
|
||||
return &change_pb.Change{
|
||||
ChangeDate: change.ChangeDate,
|
||||
EventType: message.NewLocalizedEventType(change.EventType),
|
||||
Sequence: change.Sequence,
|
||||
EditorId: change.ModifierId,
|
||||
EditorDisplayName: change.ModifierName,
|
||||
ChangeDate: change.ChangeDate,
|
||||
EventType: message.NewLocalizedEventType(change.EventType),
|
||||
Sequence: change.Sequence,
|
||||
EditorId: change.ModifierId,
|
||||
EditorDisplayName: change.ModifierName,
|
||||
EditorPreferredLoginName: change.ModifierLoginName,
|
||||
// ResourceOwnerId: change.,TODO: resource owner not returned
|
||||
}
|
||||
}
|
||||
@ -82,11 +85,12 @@ func AppChangesToPb(changes []*proj_model.ApplicationChange) []*change_pb.Change
|
||||
|
||||
func AppChangeToPb(change *proj_model.ApplicationChange) *change_pb.Change {
|
||||
return &change_pb.Change{
|
||||
ChangeDate: change.ChangeDate,
|
||||
EventType: message.NewLocalizedEventType(change.EventType),
|
||||
Sequence: change.Sequence,
|
||||
EditorId: change.ModifierId,
|
||||
EditorDisplayName: change.ModifierName,
|
||||
ChangeDate: change.ChangeDate,
|
||||
EventType: message.NewLocalizedEventType(change.EventType),
|
||||
Sequence: change.Sequence,
|
||||
EditorId: change.ModifierId,
|
||||
EditorDisplayName: change.ModifierName,
|
||||
EditorPreferredLoginName: change.ModifierLoginName,
|
||||
// ResourceOwnerId: change.,TODO: resource owner not returned
|
||||
}
|
||||
}
|
||||
|
@ -199,10 +199,12 @@ func (repo *UserRepo) MyUserChanges(ctx context.Context, lastSequence uint64, li
|
||||
}
|
||||
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
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -3,9 +3,10 @@ package model
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"github.com/golang/protobuf/ptypes/timestamp"
|
||||
|
||||
es_models "github.com/caos/zitadel/internal/eventstore/v1/models"
|
||||
iam_model "github.com/caos/zitadel/internal/iam/model"
|
||||
"github.com/golang/protobuf/ptypes/timestamp"
|
||||
)
|
||||
|
||||
type Org struct {
|
||||
@ -33,12 +34,13 @@ type OrgChanges struct {
|
||||
}
|
||||
|
||||
type OrgChange struct {
|
||||
ChangeDate *timestamp.Timestamp `json:"changeDate,omitempty"`
|
||||
EventType string `json:"eventType,omitempty"`
|
||||
Sequence uint64 `json:"sequence,omitempty"`
|
||||
ModifierId string `json:"modifierUser,omitempty"`
|
||||
ModifierName string `json:"-"`
|
||||
Data interface{} `json:"data,omitempty"`
|
||||
ChangeDate *timestamp.Timestamp `json:"changeDate,omitempty"`
|
||||
EventType string `json:"eventType,omitempty"`
|
||||
Sequence uint64 `json:"sequence,omitempty"`
|
||||
ModifierId string `json:"modifierUser,omitempty"`
|
||||
ModifierName string `json:"-"`
|
||||
ModifierLoginName string `json:"-"`
|
||||
Data interface{} `json:"data,omitempty"`
|
||||
}
|
||||
|
||||
type OrgState int32
|
||||
|
@ -22,12 +22,13 @@ type ApplicationChanges struct {
|
||||
}
|
||||
|
||||
type ApplicationChange struct {
|
||||
ChangeDate *timestamp.Timestamp `json:"changeDate,omitempty"`
|
||||
EventType string `json:"eventType,omitempty"`
|
||||
Sequence uint64 `json:"sequence,omitempty"`
|
||||
ModifierId string `json:"modifierUser,omitempty"`
|
||||
ModifierName string `json:"-"`
|
||||
Data interface{} `json:"data,omitempty"`
|
||||
ChangeDate *timestamp.Timestamp `json:"changeDate,omitempty"`
|
||||
EventType string `json:"eventType,omitempty"`
|
||||
Sequence uint64 `json:"sequence,omitempty"`
|
||||
ModifierId string `json:"modifierUser,omitempty"`
|
||||
ModifierName string `json:"-"`
|
||||
ModifierLoginName string `json:"-"`
|
||||
Data interface{} `json:"data,omitempty"`
|
||||
}
|
||||
|
||||
type AppState int32
|
||||
|
@ -24,12 +24,13 @@ type ProjectChanges struct {
|
||||
}
|
||||
|
||||
type ProjectChange struct {
|
||||
ChangeDate *timestamp.Timestamp `json:"changeDate,omitempty"`
|
||||
EventType string `json:"eventType,omitempty"`
|
||||
Sequence uint64 `json:"sequence,omitempty"`
|
||||
ModifierId string `json:"modifierUser,omitempty"`
|
||||
ModifierName string `json:"-"`
|
||||
Data interface{} `json:"data,omitempty"`
|
||||
ChangeDate *timestamp.Timestamp `json:"changeDate,omitempty"`
|
||||
EventType string `json:"eventType,omitempty"`
|
||||
Sequence uint64 `json:"sequence,omitempty"`
|
||||
ModifierId string `json:"modifierUser,omitempty"`
|
||||
ModifierName string `json:"-"`
|
||||
ModifierLoginName string `json:"-"`
|
||||
Data interface{} `json:"data,omitempty"`
|
||||
}
|
||||
|
||||
type ProjectState int32
|
||||
|
@ -10,10 +10,11 @@ type UserChanges struct {
|
||||
}
|
||||
|
||||
type UserChange struct {
|
||||
ChangeDate *timestamp.Timestamp `json:"changeDate,omitempty"`
|
||||
EventType string `json:"eventType,omitempty"`
|
||||
Sequence uint64 `json:"sequence,omitempty"`
|
||||
ModifierID string `json:"modifierUser,omitempty"`
|
||||
ModifierName string `json:"-"`
|
||||
Data interface{} `json:"data,omitempty"`
|
||||
ChangeDate *timestamp.Timestamp `json:"changeDate,omitempty"`
|
||||
EventType string `json:"eventType,omitempty"`
|
||||
Sequence uint64 `json:"sequence,omitempty"`
|
||||
ModifierID string `json:"modifierUser,omitempty"`
|
||||
ModifierName string `json:"-"`
|
||||
ModifierLoginName string `json:"-"`
|
||||
Data interface{} `json:"data,omitempty"`
|
||||
}
|
||||
|
@ -39,6 +39,12 @@ message Change {
|
||||
example: "\"69629023906488334\"";
|
||||
}
|
||||
];
|
||||
string editor_preferred_login_name = 7 [
|
||||
(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {
|
||||
description: "the preferred login name of the editor";
|
||||
example: "\"gigi@acme.zitadel.ch\"";
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
message ChangeQuery {
|
||||
|
Loading…
x
Reference in New Issue
Block a user