1
0
mirror of https://github.com/bitwarden/server.git synced 2025-07-03 00:52:49 -05:00

Changed all C# control flow block statements to include space between keyword and open paren

This commit is contained in:
Chad Scharf
2020-03-27 14:36:37 -04:00
parent 943aea9a12
commit 9800b752c0
243 changed files with 2258 additions and 2258 deletions

View File

@ -44,12 +44,12 @@ namespace Bit.Core.Services
var certThumbprint = environment.IsDevelopment() ? "207E64A231E8AA32AAF68A61037C075EBEBD553F" :
"B34876439FCDA2846505B2EFBBA6C4A951313EBE";
if(_globalSettings.SelfHosted)
if (_globalSettings.SelfHosted)
{
_certificate = CoreHelpers.GetEmbeddedCertificateAsync("licensing.cer", null)
.GetAwaiter().GetResult();
}
else if(CoreHelpers.SettingHasValue(_globalSettings.Storage?.ConnectionString) &&
else if (CoreHelpers.SettingHasValue(_globalSettings.Storage?.ConnectionString) &&
CoreHelpers.SettingHasValue(_globalSettings.LicenseCertificatePassword))
{
var storageAccount = CloudStorageAccount.Parse(globalSettings.Storage.ConnectionString);
@ -62,13 +62,13 @@ namespace Bit.Core.Services
_certificate = CoreHelpers.GetCertificate(certThumbprint);
}
if(_certificate == null || !_certificate.Thumbprint.Equals(CoreHelpers.CleanCertificateThumbprint(certThumbprint),
if (_certificate == null || !_certificate.Thumbprint.Equals(CoreHelpers.CleanCertificateThumbprint(certThumbprint),
StringComparison.InvariantCultureIgnoreCase))
{
throw new Exception("Invalid licensing certificate.");
}
if(_globalSettings.SelfHosted && !CoreHelpers.SettingHasValue(_globalSettings.LicenseDirectory))
if (_globalSettings.SelfHosted && !CoreHelpers.SettingHasValue(_globalSettings.LicenseDirectory))
{
throw new InvalidOperationException("No license directory.");
}
@ -76,7 +76,7 @@ namespace Bit.Core.Services
public async Task ValidateOrganizationsAsync()
{
if(!_globalSettings.SelfHosted)
if (!_globalSettings.SelfHosted)
{
return;
}
@ -85,29 +85,29 @@ namespace Bit.Core.Services
_logger.LogInformation(Constants.BypassFiltersEventId, null,
"Validating licenses for {0} organizations.", enabledOrgs.Count);
foreach(var org in enabledOrgs)
foreach (var org in enabledOrgs)
{
var license = ReadOrganizationLicense(org);
if(license == null)
if (license == null)
{
await DisableOrganizationAsync(org, null, "No license file.");
continue;
}
var totalLicensedOrgs = enabledOrgs.Count(o => o.LicenseKey.Equals(license.LicenseKey));
if(totalLicensedOrgs > 1)
if (totalLicensedOrgs > 1)
{
await DisableOrganizationAsync(org, license, "Multiple organizations.");
continue;
}
if(!license.VerifyData(org, _globalSettings))
if (!license.VerifyData(org, _globalSettings))
{
await DisableOrganizationAsync(org, license, "Invalid data.");
continue;
}
if(!license.VerifySignature(_certificate))
if (!license.VerifySignature(_certificate))
{
await DisableOrganizationAsync(org, license, "Invalid signature.");
continue;
@ -128,7 +128,7 @@ namespace Bit.Core.Services
public async Task ValidateUsersAsync()
{
if(!_globalSettings.SelfHosted)
if (!_globalSettings.SelfHosted)
{
return;
}
@ -137,7 +137,7 @@ namespace Bit.Core.Services
_logger.LogInformation(Constants.BypassFiltersEventId, null,
"Validating premium for {0} users.", premiumUsers.Count);
foreach(var user in premiumUsers)
foreach (var user in premiumUsers)
{
await ProcessUserValidationAsync(user);
}
@ -145,22 +145,22 @@ namespace Bit.Core.Services
public async Task<bool> ValidateUserPremiumAsync(User user)
{
if(!_globalSettings.SelfHosted)
if (!_globalSettings.SelfHosted)
{
return user.Premium;
}
if(!user.Premium)
if (!user.Premium)
{
return false;
}
// Only check once per day
var now = DateTime.UtcNow;
if(_userCheckCache.ContainsKey(user.Id))
if (_userCheckCache.ContainsKey(user.Id))
{
var lastCheck = _userCheckCache[user.Id];
if(lastCheck < now && now - lastCheck < TimeSpan.FromDays(1))
if (lastCheck < now && now - lastCheck < TimeSpan.FromDays(1))
{
return user.Premium;
}
@ -182,19 +182,19 @@ namespace Bit.Core.Services
private async Task<bool> ProcessUserValidationAsync(User user)
{
var license = ReadUserLicense(user);
if(license == null)
if (license == null)
{
await DisablePremiumAsync(user, null, "No license file.");
return false;
}
if(!license.VerifyData(user))
if (!license.VerifyData(user))
{
await DisablePremiumAsync(user, license, "Invalid data.");
return false;
}
if(!license.VerifySignature(_certificate))
if (!license.VerifySignature(_certificate))
{
await DisablePremiumAsync(user, license, "Invalid signature.");
return false;
@ -222,7 +222,7 @@ namespace Bit.Core.Services
public byte[] SignLicense(ILicense license)
{
if(_globalSettings.SelfHosted || !_certificate.HasPrivateKey)
if (_globalSettings.SelfHosted || !_certificate.HasPrivateKey)
{
throw new InvalidOperationException("Cannot sign licenses.");
}
@ -233,7 +233,7 @@ namespace Bit.Core.Services
private UserLicense ReadUserLicense(User user)
{
var filePath = $"{_globalSettings.LicenseDirectory}/user/{user.Id}.json";
if(!File.Exists(filePath))
if (!File.Exists(filePath))
{
return null;
}
@ -245,7 +245,7 @@ namespace Bit.Core.Services
private OrganizationLicense ReadOrganizationLicense(Organization organization)
{
var filePath = $"{_globalSettings.LicenseDirectory}/organization/{organization.Id}.json";
if(!File.Exists(filePath))
if (!File.Exists(filePath))
{
return null;
}