mirror of
https://github.com/bitwarden/server.git
synced 2025-04-06 21:48:12 -05:00
group/member update ids apis
This commit is contained in:
parent
7e920b955c
commit
df6d55584f
@ -139,6 +139,29 @@ namespace Bit.Api.Public.Controllers
|
|||||||
return new JsonResult(response);
|
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>
|
/// <summary>
|
||||||
/// Delete a group.
|
/// Delete a group.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -159,6 +159,29 @@ namespace Bit.Api.Public.Controllers
|
|||||||
return new JsonResult(response);
|
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>
|
/// <summary>
|
||||||
/// Delete a member.
|
/// Delete a member.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -0,0 +1,13 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace Bit.Core.Models.Api.Public
|
||||||
|
{
|
||||||
|
public class UpdateGroupIdsRequestModel
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// The associated group ids that this object can access.
|
||||||
|
/// </summary>
|
||||||
|
public IEnumerable<Guid> GroupIds { get; set; }
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,13 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace Bit.Core.Models.Api.Public
|
||||||
|
{
|
||||||
|
public class UpdateMemberIdsRequestModel
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// The associated member ids that have access to this object.
|
||||||
|
/// </summary>
|
||||||
|
public IEnumerable<Guid> MemberIds { get; set; }
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user