Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add roles to OrganizationMember #661

Merged
merged 1 commit into from
Oct 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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