From c3f9da30916ca187f8c019c755efddec5afad816 Mon Sep 17 00:00:00 2001 From: Kyle Herock Date: Wed, 10 Apr 2024 18:00:25 -0400 Subject: [PATCH] Detect organization membership by roles instead of scanning the member list --- internal/auth0/organization/resource_member.go | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/internal/auth0/organization/resource_member.go b/internal/auth0/organization/resource_member.go index 3a7f1fa59..549ecbc10 100644 --- a/internal/auth0/organization/resource_member.go +++ b/internal/auth0/organization/resource_member.go @@ -57,20 +57,12 @@ func readOrganizationMember(ctx context.Context, data *schema.ResourceData, meta api := meta.(*config.Config).GetAPI() organizationID := data.Get("organization_id").(string) + userID := data.Get("user_id").(string) - members, err := api.Organization.Members(ctx, organizationID) + _, err := api.Organization.MemberRoles(ctx, organizationID, userID) if err != nil { return diag.FromErr(internalError.HandleAPIError(data, err)) } - - userID := data.Get("user_id").(string) - for _, member := range members.Members { - if member.GetUserID() == userID { - return nil - } - } - - data.SetId("") return nil }