1
0
mirror of https://github.com/bitwarden/server.git synced 2025-07-18 16:11:28 -05:00

[PS-1909] Make LicenseKey check null safe (#2444)

* Make LicenseKey check null safe

* Catch Exception during Organization Validation

* Use null-safe check in UpdateLicense

* Formatting
This commit is contained in:
Justin Baur
2022-11-30 08:40:12 -05:00
committed by GitHub
parent 297f0c8b38
commit 8718f22ab2
2 changed files with 37 additions and 23 deletions

View File

@ -700,7 +700,7 @@ public class OrganizationService : IOrganizationService
}
var enabledOrgs = await _organizationRepository.GetManyByEnabledAsync();
if (enabledOrgs.Any(o => o.LicenseKey.Equals(license.LicenseKey)))
if (enabledOrgs.Any(o => string.Equals(o.LicenseKey, license.LicenseKey)))
{
throw new BadRequestException("License is already in use by another organization.");
}
@ -852,7 +852,7 @@ public class OrganizationService : IOrganizationService
}
var enabledOrgs = await _organizationRepository.GetManyByEnabledAsync();
if (enabledOrgs.Any(o => o.LicenseKey.Equals(license.LicenseKey) && o.Id != organizationId))
if (enabledOrgs.Any(o => string.Equals(o.LicenseKey, license.LicenseKey) && o.Id != organizationId))
{
throw new BadRequestException("License is already in use by another organization.");
}