Skip to content

Commit

Permalink
Add roles to OrganizationMember (#661)
Browse files Browse the repository at this point in the history
  • Loading branch information
frederikprijck authored Oct 19, 2023
1 parent 86e86ce commit 548a40d
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@ public class OrganizationGetAllMembersRequest {
/// <summary>
/// A comma separated list of fields to include or exclude (depending on <see cref="IncludeFields"/>) from the result, empty to retrieve all fields.
/// </summary>
/// <remarks>
/// If fields is left blank, all fields (except roles) are returned.
///
/// Member roles are not sent by default.
/// Use fields=roles to retrieve the roles assigned to each listed member.
/// To use this parameter, you must include the read:organization_member_roles scope in the token.
/// </remarks>
public string Fields { get; set; } = null;

/// <summary>
Expand Down
9 changes: 8 additions & 1 deletion src/Auth0.ManagementApi/Models/OrganizationMember.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Newtonsoft.Json;
using System.Collections.Generic;
using Newtonsoft.Json;

namespace Auth0.ManagementApi.Models
{
Expand Down Expand Up @@ -27,5 +28,11 @@ public class OrganizationMember
/// </summary>
[JsonProperty("email")]
public string Email { get; set; }

/// <summary>
/// The roles of the user
/// </summary>
[JsonProperty("roles")]
public IList<Role> Roles { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,10 @@ public async Task Test_organization_member_roles_crud_sequence()
roles.Count.Should().Be(1);
roles[0].Name.Should().Be("Admin");

var response = await fixture.ApiClient.Organizations.GetAllMembersAsync(ExistingOrganizationId, new OrganizationGetAllMembersRequest { Fields = "roles", IncludeFields = true }, new Paging.PaginationInfo());

response[0].Roles[0].Name.Should().Be("Admin");

await fixture.ApiClient.Organizations.DeleteMemberRolesAsync(ExistingOrganizationId, user.UserId, new OrganizationDeleteMemberRolesRequest
{
Roles = new List<string> { ExistingRoleId }
Expand Down

0 comments on commit 548a40d

Please sign in to comment.