mirror of
https://github.com/andwati/zitadel.git
synced 2026-11-23 05:18:46 +00:00
feat(auth): My user changes (#318)
* fix: project by id loads project from view and from eventstore * fix: correct search key for role * feat(auth): my user changes * fix: improve error handling in change converters * fix: log-id
This commit is contained in:
@@ -2,6 +2,7 @@ package grpc
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
|
||||
"github.com/caos/logging"
|
||||
"github.com/caos/zitadel/internal/api/auth"
|
||||
@@ -9,6 +10,8 @@ import (
|
||||
usr_model "github.com/caos/zitadel/internal/user/model"
|
||||
"github.com/golang/protobuf/ptypes"
|
||||
"golang.org/x/text/language"
|
||||
"google.golang.org/protobuf/encoding/protojson"
|
||||
"google.golang.org/protobuf/types/known/structpb"
|
||||
)
|
||||
|
||||
func userViewFromModel(user *usr_model.UserView) *UserView {
|
||||
@@ -335,3 +338,36 @@ func mfaTypeFromModel(mfatype usr_model.MfaType) MfaType {
|
||||
return MfaType_MFATYPE_UNSPECIFIED
|
||||
}
|
||||
}
|
||||
|
||||
func userChangesToResponse(response *usr_model.UserChanges, offset uint64, limit uint64) (_ *Changes) {
|
||||
return &Changes{
|
||||
Limit: limit,
|
||||
Offset: offset,
|
||||
Changes: userChangesToMgtAPI(response),
|
||||
}
|
||||
}
|
||||
|
||||
func userChangesToMgtAPI(changes *usr_model.UserChanges) (_ []*Change) {
|
||||
result := make([]*Change, len(changes.Changes))
|
||||
|
||||
for i, change := range changes.Changes {
|
||||
var data *structpb.Struct
|
||||
changedData, err := json.Marshal(change.Data)
|
||||
if err == nil {
|
||||
data = new(structpb.Struct)
|
||||
err = protojson.Unmarshal(changedData, data)
|
||||
logging.Log("GRPC-0kRsY").OnError(err).Debug("unable to marshal changed data to struct")
|
||||
}
|
||||
|
||||
result[i] = &Change{
|
||||
ChangeDate: change.ChangeDate,
|
||||
EventType: change.EventType,
|
||||
Sequence: change.Sequence,
|
||||
Data: data,
|
||||
EditorId: change.ModifierId,
|
||||
Editor: change.ModifierName,
|
||||
}
|
||||
}
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user