From 9a6dab14d935f046bd17f471e1ff599849a8f637 Mon Sep 17 00:00:00 2001 From: Haris Chaniotakis Date: Tue, 14 Nov 2023 09:29:39 +0200 Subject: [PATCH] fix: Accept role ID instead of Key for organization settings creator role We update the logic of the instance organization settings method in order to accept a role ID instead of a Key for the default creator role. This is because we should use an immutable identifier instead of the Key which customers are able to modify --- clerk/instances.go | 2 +- clerk/instances_test.go | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/clerk/instances.go b/clerk/instances.go index 4767ce69..71a4018a 100644 --- a/clerk/instances.go +++ b/clerk/instances.go @@ -100,7 +100,7 @@ type UpdateOrganizationSettingsParams struct { AdminDeleteEnabled *bool `json:"admin_delete_enabled,omitempty"` DomainsEnabled *bool `json:"domains_enabled,omitempty"` DomainsEnrollmentModes []string `json:"domains_enrollment_modes,omitempty"` - CreatorRole *string `json:"creator_role,omitempty"` + CreatorRoleID *string `json:"creator_role_id,omitempty"` } func (s *InstanceService) UpdateOrganizationSettings(params UpdateOrganizationSettingsParams) (*OrganizationSettingsResponse, error) { diff --git a/clerk/instances_test.go b/clerk/instances_test.go index a4e1dc14..7f976956 100644 --- a/clerk/instances_test.go +++ b/clerk/instances_test.go @@ -126,10 +126,9 @@ func TestInstanceService_UpdateOrganizationSettings_happyPath(t *testing.T) { }) enabled := true - defaultCreatorRole := "org:custom_admin" got, _ := client.Instances().UpdateOrganizationSettings(UpdateOrganizationSettingsParams{ - Enabled: &enabled, - CreatorRole: &defaultCreatorRole, + Enabled: &enabled, + CreatorRoleID: stringToPtr("role_2XcSZn6swGCjX59Nk0XbGer22jb"), }) assert.Equal(t, &organizationSettingsResponse, got)