Skip to content

Commit

Permalink
fix(user fields): missing creationDate in details
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinRSI committed Jan 27, 2025
1 parent ec5f18c commit 7f60d8d
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 0 deletions.
3 changes: 3 additions & 0 deletions internal/api/grpc/object/v2/converter.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ func DomainToDetailsPb(objectDetail *domain.ObjectDetails) *object.Details {
if !objectDetail.EventDate.IsZero() {
details.ChangeDate = timestamppb.New(objectDetail.EventDate)
}
if !objectDetail.CreationDate.IsZero() {
details.CreationDate = timestamppb.New(objectDetail.CreationDate)
}
return details
}

Expand Down
16 changes: 16 additions & 0 deletions internal/api/grpc/user/v2/passkey_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ func Test_passkeyRegistrationDetailsToPb(t *testing.T) {
ObjectDetails: &domain.ObjectDetails{
Sequence: 22,
EventDate: time.Unix(3000, 22),
CreationDate: time.Unix(3000, 22),
ResourceOwner: "me",
},
ID: "123",
Expand All @@ -90,6 +91,7 @@ func Test_passkeyRegistrationDetailsToPb(t *testing.T) {
ObjectDetails: &domain.ObjectDetails{
Sequence: 22,
EventDate: time.Unix(3000, 22),
CreationDate: time.Unix(3000, 22),
ResourceOwner: "me",
},
ID: "123",
Expand All @@ -104,6 +106,10 @@ func Test_passkeyRegistrationDetailsToPb(t *testing.T) {
Seconds: 3000,
Nanos: 22,
},
CreationDate: &timestamppb.Timestamp{
Seconds: 3000,
Nanos: 22,
},
ResourceOwner: "me",
},
PasskeyId: "123",
Expand Down Expand Up @@ -150,6 +156,7 @@ func Test_passkeyDetailsToPb(t *testing.T) {
details: &domain.ObjectDetails{
Sequence: 22,
EventDate: time.Unix(3000, 22),
CreationDate: time.Unix(3000, 22),
ResourceOwner: "me",
},
err: nil,
Expand All @@ -161,6 +168,10 @@ func Test_passkeyDetailsToPb(t *testing.T) {
Seconds: 3000,
Nanos: 22,
},
CreationDate: &timestamppb.Timestamp{
Seconds: 3000,
Nanos: 22,
},
ResourceOwner: "me",
},
},
Expand Down Expand Up @@ -199,6 +210,7 @@ func Test_passkeyCodeDetailsToPb(t *testing.T) {
ObjectDetails: &domain.ObjectDetails{
Sequence: 22,
EventDate: time.Unix(3000, 22),
CreationDate: time.Unix(3000, 22),
ResourceOwner: "me",
},
CodeID: "123",
Expand All @@ -213,6 +225,10 @@ func Test_passkeyCodeDetailsToPb(t *testing.T) {
Seconds: 3000,
Nanos: 22,
},
CreationDate: &timestamppb.Timestamp{
Seconds: 3000,
Nanos: 22,
},
ResourceOwner: "me",
},
Code: &user.PasskeyRegistrationCode{
Expand Down
1 change: 1 addition & 0 deletions internal/api/grpc/user/v2/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ func userToPb(userQ *query.User, assetPrefix string) *user.User {
Sequence: userQ.Sequence,
EventDate: userQ.ChangeDate,
ResourceOwner: userQ.ResourceOwner,
CreationDate: userQ.CreationDate,
}),
State: userStateToPb(userQ.State),
Username: userQ.Username,
Expand Down
6 changes: 6 additions & 0 deletions internal/api/grpc/user/v2/u2f_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ func Test_u2fRegistrationDetailsToPb(t *testing.T) {
ObjectDetails: &domain.ObjectDetails{
Sequence: 22,
EventDate: time.Unix(3000, 22),
CreationDate: time.Unix(3000, 22),
ResourceOwner: "me",
},
ID: "123",
Expand All @@ -59,6 +60,7 @@ func Test_u2fRegistrationDetailsToPb(t *testing.T) {
ObjectDetails: &domain.ObjectDetails{
Sequence: 22,
EventDate: time.Unix(3000, 22),
CreationDate: time.Unix(3000, 22),
ResourceOwner: "me",
},
ID: "123",
Expand All @@ -73,6 +75,10 @@ func Test_u2fRegistrationDetailsToPb(t *testing.T) {
Seconds: 3000,
Nanos: 22,
},
CreationDate: &timestamppb.Timestamp{
Seconds: 3000,
Nanos: 22,
},
ResourceOwner: "me",
},
U2FId: "123",
Expand Down
6 changes: 6 additions & 0 deletions proto/zitadel/object/v2/object.proto
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,12 @@ message Details {
(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {
example: "\"69629023906488334\"";
}
//creation_date is the timestamp where the first operation on the object was made
//
// on read: the timestamp of the first event of the object
//
// on create: the timestamp of the event(s) added by the manipulation
google.protobuf.Timestamp creation_date = 4;
];
}

Expand Down

0 comments on commit 7f60d8d

Please sign in to comment.