From 72750cf298917061f7b516bfb6e8a73804656830 Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Mon, 7 Oct 2019 16:23:38 -0400 Subject: [PATCH] org re-invite api --- .../Public/Controllers/MembersController.cs | 22 +++++++++++++++++++ src/Core/Services/IOrganizationService.cs | 2 +- .../Implementations/OrganizationService.cs | 2 +- 3 files changed, 24 insertions(+), 2 deletions(-) diff --git a/src/Api/Public/Controllers/MembersController.cs b/src/Api/Public/Controllers/MembersController.cs index 93ed8e1a7..882d8fc06 100644 --- a/src/Api/Public/Controllers/MembersController.cs +++ b/src/Api/Public/Controllers/MembersController.cs @@ -203,5 +203,27 @@ namespace Bit.Api.Public.Controllers await _organizationService.DeleteUserAsync(_currentContext.OrganizationId.Value, id, null); return new OkResult(); } + + /// + /// Re-invite a member. + /// + /// + /// Re-sends the invitation email to an organization member. + /// + /// The identifier of the member to re-invite. + [HttpPost("{id}/reinvite")] + [ProducesResponseType((int)HttpStatusCode.OK)] + [ProducesResponseType(typeof(ErrorResponseModel), (int)HttpStatusCode.BadRequest)] + [ProducesResponseType((int)HttpStatusCode.NotFound)] + public async Task PostReinvite(Guid id) + { + var existingUser = await _organizationUserRepository.GetByIdAsync(id); + if(existingUser == null || existingUser.OrganizationId != _currentContext.OrganizationId) + { + return new NotFoundResult(); + } + await _organizationService.ResendInviteAsync(_currentContext.OrganizationId.Value, null, id); + return new OkResult(); + } } } diff --git a/src/Core/Services/IOrganizationService.cs b/src/Core/Services/IOrganizationService.cs index 24c73b6c3..c59472d03 100644 --- a/src/Core/Services/IOrganizationService.cs +++ b/src/Core/Services/IOrganizationService.cs @@ -33,7 +33,7 @@ namespace Bit.Core.Services OrganizationUserType type, bool accessAll, string externalId, IEnumerable collections); Task> InviteUserAsync(Guid organizationId, Guid? invitingUserId, IEnumerable emails, OrganizationUserType type, bool accessAll, string externalId, IEnumerable collections); - Task ResendInviteAsync(Guid organizationId, Guid invitingUserId, Guid organizationUserId); + Task ResendInviteAsync(Guid organizationId, Guid? invitingUserId, Guid organizationUserId); Task AcceptUserAsync(Guid organizationUserId, User user, string token); Task ConfirmUserAsync(Guid organizationId, Guid organizationUserId, string key, Guid confirmingUserId); Task SaveUserAsync(OrganizationUser user, Guid? savingUserId, IEnumerable collections); diff --git a/src/Core/Services/Implementations/OrganizationService.cs b/src/Core/Services/Implementations/OrganizationService.cs index f69847320..683b073f6 100644 --- a/src/Core/Services/Implementations/OrganizationService.cs +++ b/src/Core/Services/Implementations/OrganizationService.cs @@ -914,7 +914,7 @@ namespace Bit.Core.Services return orgUsers; } - public async Task ResendInviteAsync(Guid organizationId, Guid invitingUserId, Guid organizationUserId) + public async Task ResendInviteAsync(Guid organizationId, Guid? invitingUserId, Guid organizationUserId) { var orgUser = await _organizationUserRepository.GetByIdAsync(organizationUserId); if(orgUser == null || orgUser.OrganizationId != organizationId ||