File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -170,10 +170,11 @@ func (s *AccountService) GetMe(
170170 return nil , err
171171 }
172172 var envRoles []* accountproto.ConsoleAccount_EnvironmentRole
173- if account .OrganizationRole == accountproto .AccountV2_Role_Organization_ADMIN {
174- envRoles = s .getAdminConsoleAccountEnvironmentRoles (environments , projects )
175- } else {
173+ if account .OrganizationRole == accountproto .AccountV2_Role_Organization_MEMBER {
176174 envRoles = s .getConsoleAccountEnvironmentRoles (account .EnvironmentRoles , environments , projects )
175+ } else {
176+ // If the account is an organization admin or organization owner can view all environments
177+ envRoles = s .getAdminConsoleAccountEnvironmentRoles (environments , projects )
177178 }
178179
179180 // update user last seen
@@ -417,9 +418,10 @@ func (s *AccountService) getMyOrganizations(
417418 if accWithOrg .AccountV2 .Disabled || accWithOrg .Organization .Disabled || accWithOrg .Organization .Archived {
418419 continue
419420 }
420- // If the account is an admin account , we append the organization.
421+ // If the account is an organization admin or organization owner , we append the organization.
421422 // Otherwise, we check if the account is enabled in any environment in this organization.
422- if accWithOrg .AccountV2 .OrganizationRole == accountproto .AccountV2_Role_Organization_ADMIN {
423+ if accWithOrg .AccountV2 .OrganizationRole == accountproto .AccountV2_Role_Organization_ADMIN ||
424+ accWithOrg .AccountV2 .OrganizationRole == accountproto .AccountV2_Role_Organization_OWNER {
423425 myOrgs = append (myOrgs , accWithOrg .Organization )
424426 continue
425427 }
Original file line number Diff line number Diff line change @@ -634,10 +634,7 @@ func (s *AccountService) getAllowedEnvironments(
634634 editor * eventproto.Editor ,
635635) []string {
636636 filterEnvironmentIDs := make ([]string , 0 )
637- if editor .OrganizationRole == proto .AccountV2_Role_Organization_ADMIN || editor .IsAdmin {
638- // if the user is an admin, no need to filter environments.
639- filterEnvironmentIDs = append (filterEnvironmentIDs , reqEnvironmentIDs ... )
640- } else {
637+ if editor .OrganizationRole == proto .AccountV2_Role_Organization_MEMBER {
641638 // only show API keys in allowed environments for member.
642639 if len (reqEnvironmentIDs ) > 0 {
643640 for _ , id := range reqEnvironmentIDs {
@@ -653,6 +650,9 @@ func (s *AccountService) getAllowedEnvironments(
653650 filterEnvironmentIDs = append (filterEnvironmentIDs , e .EnvironmentId )
654651 }
655652 }
653+ } else {
654+ // if the user is an admin, no need to filter environments.
655+ filterEnvironmentIDs = append (filterEnvironmentIDs , reqEnvironmentIDs ... )
656656 }
657657 return filterEnvironmentIDs
658658}
Original file line number Diff line number Diff line change @@ -144,7 +144,8 @@ func (a *AccountV2) Update(
144144 if len (environmentRoles ) > 0 {
145145 updated .EnvironmentRoles = environmentRoles
146146 }
147- if updated .OrganizationRole == proto .AccountV2_Role_Organization_ADMIN {
147+ if updated .OrganizationRole == proto .AccountV2_Role_Organization_ADMIN ||
148+ updated .OrganizationRole == proto .AccountV2_Role_Organization_OWNER {
148149 updated .EnvironmentRoles = []* proto.AccountV2_EnvironmentRole {}
149150 }
150151 if isDisabled != nil {
Original file line number Diff line number Diff line change @@ -771,10 +771,7 @@ func (s *NotificationService) getAllowedEnvironments(
771771 editor * eventproto.Editor ,
772772) []string {
773773 filterEnvironmentIDs := make ([]string , 0 )
774- if editor .OrganizationRole == accountproto .AccountV2_Role_Organization_ADMIN || editor .IsAdmin {
775- // if the user is an admin, no need to filter environments.
776- filterEnvironmentIDs = append (filterEnvironmentIDs , reqEnvironmentIDs ... )
777- } else {
774+ if editor .OrganizationRole == accountproto .AccountV2_Role_Organization_MEMBER {
778775 // only show API keys in allowed environments for member.
779776 if len (reqEnvironmentIDs ) > 0 {
780777 for _ , id := range reqEnvironmentIDs {
@@ -790,6 +787,9 @@ func (s *NotificationService) getAllowedEnvironments(
790787 filterEnvironmentIDs = append (filterEnvironmentIDs , e .EnvironmentId )
791788 }
792789 }
790+ } else {
791+ // if the user is an organization admin or organization owner, no need to filter environments.
792+ filterEnvironmentIDs = append (filterEnvironmentIDs , reqEnvironmentIDs ... )
793793 }
794794 return filterEnvironmentIDs
795795}
Original file line number Diff line number Diff line change @@ -1095,10 +1095,7 @@ func (s *PushService) getAllowedEnvironments(
10951095 editor * eventproto.Editor ,
10961096) []string {
10971097 filterEnvironmentIDs := make ([]string , 0 )
1098- if editor .OrganizationRole == accountproto .AccountV2_Role_Organization_ADMIN || editor .IsAdmin {
1099- // if the user is an admin, no need to filter environments.
1100- filterEnvironmentIDs = append (filterEnvironmentIDs , reqEnvironmentIDs ... )
1101- } else {
1098+ if editor .OrganizationRole == accountproto .AccountV2_Role_Organization_MEMBER {
11021099 // only show API keys in allowed environments for member.
11031100 if len (reqEnvironmentIDs ) > 0 {
11041101 for _ , id := range reqEnvironmentIDs {
@@ -1114,6 +1111,9 @@ func (s *PushService) getAllowedEnvironments(
11141111 filterEnvironmentIDs = append (filterEnvironmentIDs , e .EnvironmentId )
11151112 }
11161113 }
1114+ } else {
1115+ // if the user is an admin, no need to filter environments.
1116+ filterEnvironmentIDs = append (filterEnvironmentIDs , reqEnvironmentIDs ... )
11171117 }
11181118 return filterEnvironmentIDs
11191119}
Original file line number Diff line number Diff line change @@ -645,10 +645,7 @@ func (s *TagService) getAllowedEnvironments(
645645 editor * eventproto.Editor ,
646646) []string {
647647 filterEnvironmentIDs := make ([]string , 0 )
648- if editor .OrganizationRole == accproto .AccountV2_Role_Organization_ADMIN || editor .IsAdmin {
649- // if the user is an admin, no need to filter environments.
650- filterEnvironmentIDs = append (filterEnvironmentIDs , reqEnvironmentIDs ... )
651- } else {
648+ if editor .OrganizationRole == accproto .AccountV2_Role_Organization_MEMBER {
652649 // only show API keys in allowed environments for member.
653650 if len (reqEnvironmentIDs ) > 0 {
654651 for _ , id := range reqEnvironmentIDs {
@@ -664,6 +661,9 @@ func (s *TagService) getAllowedEnvironments(
664661 filterEnvironmentIDs = append (filterEnvironmentIDs , e .EnvironmentId )
665662 }
666663 }
664+ } else {
665+ // if the user is an admin, no need to filter environments.
666+ filterEnvironmentIDs = append (filterEnvironmentIDs , reqEnvironmentIDs ... )
667667 }
668668 return filterEnvironmentIDs
669669}
You can’t perform that action at this time.
0 commit comments