mirror of
https://github.com/andwati/zitadel.git
synced 2026-11-21 20:38:47 +00:00
feat: set metadata at the user level in CreateUser request (#11719)
# Which Problems Are Solved Currently, metadata can be set/updated only for human users, but it should be available also for service accounts (machine users). # How the Problems Are Solved This is achieved by: - adding a metadata field at the root level in `CreateUserRequest`, which makes it available for both `human` and `machine` user types - returning an error when both the root level and human-level `metadata` fields are set in the `CreateUserRequest` - setting `human` and `machine` metadata from the root `metadata` field in the server layer - pushing `user.metadata.set` event during machine user creation in the command layer - adding integration tests # Additional Changes N/A # Additional Context - Related to https://github.com/zitadel/zitadel/issues/11369 --------- Co-authored-by: Vitor Bari Buccianti <[email protected]> Co-authored-by: Silvan <[email protected]>
This commit is contained in:
co-authored by
Vitor Bari Buccianti
Silvan
parent
92a628d892
commit
4aacfa842f
@@ -12,7 +12,14 @@ import (
|
||||
"github.com/zitadel/zitadel/pkg/grpc/user/v2"
|
||||
)
|
||||
|
||||
func (s *Server) createUserTypeMachine(ctx context.Context, machinePb *user.CreateUserRequest_Machine, orgId, userName, userId string) (*connect.Response[user.CreateUserResponse], error) {
|
||||
func (s *Server) createUserTypeMachine(ctx context.Context, machinePb *user.CreateUserRequest_Machine, orgId, userName, userId string, reqMetadata []*user.Metadata) (*connect.Response[user.CreateUserResponse], error) {
|
||||
metadata := make([]*command.AddMetadataEntry, len(reqMetadata))
|
||||
for i, metadataEntry := range reqMetadata {
|
||||
metadata[i] = &command.AddMetadataEntry{
|
||||
Key: metadataEntry.GetKey(),
|
||||
Value: metadataEntry.GetValue(),
|
||||
}
|
||||
}
|
||||
cmd := &command.Machine{
|
||||
Username: userName,
|
||||
Name: machinePb.Name,
|
||||
@@ -22,6 +29,7 @@ func (s *Server) createUserTypeMachine(ctx context.Context, machinePb *user.Crea
|
||||
ResourceOwner: orgId,
|
||||
AggregateID: userId,
|
||||
},
|
||||
Metadata: metadata,
|
||||
}
|
||||
details, err := s.command.AddMachine(
|
||||
ctx,
|
||||
|
||||
Reference in New Issue
Block a user