diff --git a/src/Core/Services/Implementations/OrganizationService.cs b/src/Core/Services/Implementations/OrganizationService.cs index 3bad0c213e..716fb00ca1 100644 --- a/src/Core/Services/Implementations/OrganizationService.cs +++ b/src/Core/Services/Implementations/OrganizationService.cs @@ -930,7 +930,7 @@ namespace Bit.Core.Services public async Task AcceptUserAsync(Guid organizationUserId, User user, string token) { var orgUser = await _organizationUserRepository.GetByIdAsync(organizationUserId); - if(orgUser == null || !orgUser.Email.Equals(user.Email, StringComparison.InvariantCultureIgnoreCase)) + if(orgUser == null) { throw new BadRequestException("User invalid."); } @@ -940,6 +940,12 @@ namespace Bit.Core.Services throw new BadRequestException("Already accepted."); } + if(string.IsNullOrWhiteSpace(orgUser.Email) || + !orgUser.Email.Equals(user.Email, StringComparison.InvariantCultureIgnoreCase)) + { + throw new BadRequestException("User email does not match invite."); + } + if(orgUser.Type == OrganizationUserType.Owner || orgUser.Type == OrganizationUserType.Admin) { var org = await GetOrgById(orgUser.OrganizationId);