1
0
mirror of https://github.com/bitwarden/server.git synced 2025-02-17 02:01:53 +01:00

Fix error message if already accepted EA invite (#1159)

* Fix error message if already accepted EA invite

* Fix error message wording depending on EA status
This commit is contained in:
Thomas Rittson 2021-02-24 05:46:52 +10:00 committed by GitHub
parent cc964ccb9c
commit 499c30a805
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -116,17 +116,21 @@ namespace Bit.Core.Services
throw new BadRequestException("Invalid token.");
}
if (emergencyAccess.Status == EmergencyAccessStatusType.Accepted)
{
throw new BadRequestException("Invitation already accepted. You will receive an email when the grantor confirms you as an emergency access contact.");
}
else if (emergencyAccess.Status != EmergencyAccessStatusType.Invited)
{
throw new BadRequestException("Invitation already accepted.");
}
if (string.IsNullOrWhiteSpace(emergencyAccess.Email) ||
!emergencyAccess.Email.Equals(user.Email, StringComparison.InvariantCultureIgnoreCase))
{
throw new BadRequestException("User email does not match invite.");
}
if (emergencyAccess.Status != EmergencyAccessStatusType.Invited)
{
throw new BadRequestException("Already accepted.");
}
var granteeEmail = emergencyAccess.Email;
emergencyAccess.Status = EmergencyAccessStatusType.Accepted;