preUndeleteUserGuard checks seat limits before reactivating a principal. A soft-deleted principal does not occupy a seat, so undeleting one that is already referenced by workspace IAM (via allUsers, a direct binding, or a group) re-occupies a seat and must respect the limit. When the principal is no
(ctx context.Context, workspaceID string, user *store.UserMessage)
| 958 | // group) re-occupies a seat and must respect the limit. When the principal is |
| 959 | // not referenced, undeleting adds no seat and is always allowed. |
| 960 | func (s *UserService) preUndeleteUserGuard(ctx context.Context, workspaceID string, user *store.UserMessage) error { |
| 961 | p, err := s.store.GetWorkspaceIamPolicy(ctx, workspaceID) |
| 962 | if err != nil { |
| 963 | return connect.NewError(connect.CodeInternal, errors.Wrap(err, "failed to get workspace IAM policy")) |
| 964 | } |
| 965 | if len(utils.GetUserIAMPolicyBindings(ctx, s.store, workspaceID, user, p.Policy)) == 0 { |
| 966 | return nil |
| 967 | } |
| 968 | return userCountGuard(ctx, s.store, s.licenseService, workspaceID, p.Policy, s.profile.SaaS) |
| 969 | } |
| 970 | |
| 971 | func policyContainsAllUsers(policy *storepb.IamPolicy) bool { |
| 972 | for _, binding := range policy.Bindings { |
no test coverage detected