1
0
mirror of https://github.com/bitwarden/server.git synced 2025-07-05 10:02:47 -05:00

get group member ids and member group ids apis

This commit is contained in:
Kyle Spearrin
2019-03-12 11:35:03 -04:00
parent b6f54324a5
commit 3187afdb0b
2 changed files with 49 additions and 0 deletions

View File

@ -1,4 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Threading.Tasks;
@ -52,6 +53,28 @@ namespace Bit.Api.Public.Controllers
return new JsonResult(response);
}
/// <summary>
/// Retrieve a groups's member ids
/// </summary>
/// <remarks>
/// Retrieves the unique identifiers for all members that are associated with this group. You need only
/// supply the unique group identifier that was returned upon group creation.
/// </remarks>
/// <param name="id">The identifier of the group to be retrieved.</param>
[HttpGet("{id}/member-ids")]
[ProducesResponseType(typeof(HashSet<Guid>), (int)HttpStatusCode.OK)]
[ProducesResponseType((int)HttpStatusCode.NotFound)]
public async Task<IActionResult> GetMemberIds(Guid id)
{
var group = await _groupRepository.GetByIdAsync(id);
if(group == null || group.OrganizationId != _currentContext.OrganizationId)
{
return new NotFoundResult();
}
var orgUserIds = await _groupRepository.GetManyUserIdsByIdAsync(id);
return new JsonResult(orgUserIds);
}
/// <summary>
/// List all groups.
/// </summary>