Skip to content

Commit

Permalink
Detect organization membership by roles instead of scanning the membe…
Browse files Browse the repository at this point in the history
…r list
  • Loading branch information
kherock committed May 22, 2024
1 parent 525eba1 commit c3f9da3
Showing 1 changed file with 2 additions and 10 deletions.
12 changes: 2 additions & 10 deletions internal/auth0/organization/resource_member.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down

0 comments on commit c3f9da3

Please sign in to comment.