mirror of
https://github.com/bitwarden/server.git
synced 2025-05-22 12:04:27 -05:00
Log org disabled reason
This commit is contained in:
parent
78af77036b
commit
ad03c9a157
@ -70,21 +70,32 @@ namespace Bit.Core.Services
|
|||||||
var license = ReadOrganiztionLicense(org);
|
var license = ReadOrganiztionLicense(org);
|
||||||
if(license == null)
|
if(license == null)
|
||||||
{
|
{
|
||||||
await DisableOrganizationAsync(org, null);
|
await DisableOrganizationAsync(org, null, "No license file.");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
var totalLicensedOrgs = enabledOrgs.Count(o => o.LicenseKey.Equals(license.LicenseKey));
|
var totalLicensedOrgs = enabledOrgs.Count(o => o.LicenseKey.Equals(license.LicenseKey));
|
||||||
if(totalLicensedOrgs > 1 || !license.VerifyData(org, _globalSettings) || !license.VerifySignature(_certificate))
|
if(totalLicensedOrgs > 1)
|
||||||
{
|
{
|
||||||
await DisableOrganizationAsync(org, license);
|
await DisableOrganizationAsync(org, license, "Multiple organizations.");
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!license.VerifyData(org, _globalSettings))
|
||||||
|
{
|
||||||
|
await DisableOrganizationAsync(org, license, "Invalid data.");
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!license.VerifySignature(_certificate))
|
||||||
|
{
|
||||||
|
await DisableOrganizationAsync(org, license, "Invalid signature.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task DisableOrganizationAsync(Organization org, ILicense license)
|
private async Task DisableOrganizationAsync(Organization org, ILicense license, string reason)
|
||||||
{
|
{
|
||||||
_logger.LogInformation("Organization {0}({1}) has an invalid license and is being disabled.", org.Id, org.Name);
|
_logger.LogInformation("Organization {0} ({1}) has an invalid license and is being disabled. Reason: {2}",
|
||||||
|
org.Id, org.Name, reason);
|
||||||
org.Enabled = false;
|
org.Enabled = false;
|
||||||
org.ExpirationDate = license?.Expires ?? DateTime.UtcNow;
|
org.ExpirationDate = license?.Expires ?? DateTime.UtcNow;
|
||||||
org.RevisionDate = DateTime.UtcNow;
|
org.RevisionDate = DateTime.UtcNow;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user