mirror of
https://github.com/bitwarden/server.git
synced 2025-07-02 00:22:50 -05:00
group/member update ids apis
This commit is contained in:
@ -139,6 +139,29 @@ namespace Bit.Api.Public.Controllers
|
||||
return new JsonResult(response);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Update a group's members.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Updates the specified group's member associations.
|
||||
/// </remarks>
|
||||
/// <param name="id">The identifier of the group to be updated.</param>
|
||||
/// <param name="model">The request model.</param>
|
||||
[HttpPut("{id}/member-ids")]
|
||||
[ProducesResponseType((int)HttpStatusCode.OK)]
|
||||
[ProducesResponseType(typeof(ErrorResponseModel), (int)HttpStatusCode.BadRequest)]
|
||||
[ProducesResponseType((int)HttpStatusCode.NotFound)]
|
||||
public async Task<IActionResult> PutMemberIds(Guid id, [FromBody]UpdateMemberIdsRequestModel model)
|
||||
{
|
||||
var existingGroup = await _groupRepository.GetByIdAsync(id);
|
||||
if(existingGroup == null || existingGroup.OrganizationId != _currentContext.OrganizationId)
|
||||
{
|
||||
return new NotFoundResult();
|
||||
}
|
||||
await _groupRepository.UpdateUsersAsync(existingGroup.Id, model.MemberIds);
|
||||
return new OkResult();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Delete a group.
|
||||
/// </summary>
|
||||
|
@ -159,6 +159,29 @@ namespace Bit.Api.Public.Controllers
|
||||
return new JsonResult(response);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Update a member's groups.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Updates the specified member's group associations.
|
||||
/// </remarks>
|
||||
/// <param name="id">The identifier of the member to be updated.</param>
|
||||
/// <param name="model">The request model.</param>
|
||||
[HttpPut("{id}/group-ids")]
|
||||
[ProducesResponseType((int)HttpStatusCode.OK)]
|
||||
[ProducesResponseType(typeof(ErrorResponseModel), (int)HttpStatusCode.BadRequest)]
|
||||
[ProducesResponseType((int)HttpStatusCode.NotFound)]
|
||||
public async Task<IActionResult> PutGroupIds(Guid id, [FromBody]UpdateGroupIdsRequestModel model)
|
||||
{
|
||||
var existingUser = await _organizationUserRepository.GetByIdAsync(id);
|
||||
if(existingUser == null || existingUser.OrganizationId != _currentContext.OrganizationId)
|
||||
{
|
||||
return new NotFoundResult();
|
||||
}
|
||||
await _organizationService.UpdateUserGroupsAsync(existingUser, model.GroupIds);
|
||||
return new OkResult();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Delete a member.
|
||||
/// </summary>
|
||||
|
Reference in New Issue
Block a user