From ad6abaccc8d336d16480ad9660e5f6f3afed3466 Mon Sep 17 00:00:00 2001 From: Thomas Rittson <31796059+eliykat@users.noreply.github.com> Date: Wed, 17 Feb 2021 10:28:49 +1100 Subject: [PATCH] Fix error message if user already accepted invite (#1140) * Fix error message if already accepted invitation * Improve error message wording * Use consistent capitalization of organization --- .../Implementations/OrganizationService.cs | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/Core/Services/Implementations/OrganizationService.cs b/src/Core/Services/Implementations/OrganizationService.cs index 62586858bb..3795f4eb09 100644 --- a/src/Core/Services/Implementations/OrganizationService.cs +++ b/src/Core/Services/Implementations/OrganizationService.cs @@ -1094,19 +1094,23 @@ namespace Bit.Core.Services throw new BadRequestException("Invalid token."); } - if (string.IsNullOrWhiteSpace(orgUser.Email) || - !orgUser.Email.Equals(user.Email, StringComparison.InvariantCultureIgnoreCase)) - { - throw new BadRequestException("User email does not match invite."); - } - var existingOrgUserCount = await _organizationUserRepository.GetCountByOrganizationAsync( orgUser.OrganizationId, user.Email, true); if (existingOrgUserCount > 0) { + if (orgUser.Status == OrganizationUserStatusType.Accepted) + { + throw new BadRequestException("Invitation already accepted. You will receive an email when your organization membership is confirmed."); + } throw new BadRequestException("You are already part of this organization."); } + if (string.IsNullOrWhiteSpace(orgUser.Email) || + !orgUser.Email.Equals(user.Email, StringComparison.InvariantCultureIgnoreCase)) + { + throw new BadRequestException("User email does not match invite."); + } + return await AcceptUserAsync(orgUser, user, userService); }