Add IAM_OWNER if its firstOrg admin
[ZITADOPER-5]
This commit is contained in:
@@ -159,6 +159,12 @@ func (wr *wrappedOrganizationReconciler) reconcileInitialAdmin(ctx context.Conte
|
||||
}
|
||||
}
|
||||
ctx = middleware.SetOrgID(ctx, wr.organization.Status.OrgId)
|
||||
roles := []string{
|
||||
"ORG_OWNER",
|
||||
}
|
||||
if wr.organization.Name == zitadelCluster.Spec.FirstOrgName {
|
||||
roles = append(roles, "IAM_OWNER")
|
||||
}
|
||||
var userid string
|
||||
if adminUser == nil {
|
||||
resp, err := ztdClient.AddHumanUser(ctx, &pb.AddHumanUserRequest{
|
||||
@@ -179,9 +185,7 @@ func (wr *wrappedOrganizationReconciler) reconcileInitialAdmin(ctx context.Conte
|
||||
{
|
||||
if _, err := ztdClient.AddOrgMember(ctx, &pb.AddOrgMemberRequest{
|
||||
UserId: userid,
|
||||
Roles: []string{
|
||||
"ORG_OWNER",
|
||||
},
|
||||
Roles: roles,
|
||||
}); err != nil {
|
||||
if !strings.Contains(err.Error(), "Errors.Org.Member.RolesNotChanged") {
|
||||
return fmt.Errorf("Error adding org member: %v", err)
|
||||
@@ -195,9 +199,7 @@ func (wr *wrappedOrganizationReconciler) reconcileInitialAdmin(ctx context.Conte
|
||||
{
|
||||
if _, err := ztdClient.UpdateOrgMember(ctx, &pb.UpdateOrgMemberRequest{
|
||||
UserId: userid,
|
||||
Roles: []string{
|
||||
"ORG_OWNER",
|
||||
},
|
||||
Roles: roles,
|
||||
}); err != nil {
|
||||
if !strings.Contains(err.Error(), "Errors.Org.Member.RolesNotChanged") {
|
||||
return fmt.Errorf("Error updating org member: %v", err)
|
||||
|
||||
Reference in New Issue
Block a user