1
0
mirror of https://github.com/bitwarden/server.git synced 2025-07-07 10:55:43 -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

@ -58,7 +58,7 @@ namespace Bit.Billing.Models
{
var cancellationDate = GetLastCancellationDate();
var expiresDate = GetLastCancellationDate();
if(cancellationDate.HasValue && expiresDate.HasValue)
if (cancellationDate.HasValue && expiresDate.HasValue)
{
return cancellationDate.Value <= expiresDate.Value;
}

View File

@ -19,7 +19,7 @@ namespace Bit.Core.Models.Business
public BillingSource(PaymentMethod method)
{
if(method.Card != null)
if (method.Card != null)
{
Type = PaymentMethodType.Card;
Description = $"{method.Card.Brand?.ToUpperInvariant()}, *{method.Card.Last4}, " +
@ -33,7 +33,7 @@ namespace Bit.Core.Models.Business
public BillingSource(IPaymentSource source)
{
if(source is BankAccount bankAccount)
if (source is BankAccount bankAccount)
{
Type = PaymentMethodType.BankAccount;
Description = $"{bankAccount.BankName}, *{bankAccount.Last4} - " +
@ -42,7 +42,7 @@ namespace Bit.Core.Models.Business
bankAccount.Status == "verification_failed" ? "verification failed" : "unverified");
NeedsVerification = bankAccount.Status == "new" || bankAccount.Status == "validated";
}
else if(source is Card card)
else if (source is Card card)
{
Type = PaymentMethodType.Card;
Description = $"{card.Brand}, *{card.Last4}, " +
@ -52,7 +52,7 @@ namespace Bit.Core.Models.Business
card.ExpYear);
CardBrand = card.Brand;
}
else if(source is Source src && src.Card != null)
else if (source is Source src && src.Card != null)
{
Type = PaymentMethodType.Card;
Description = $"{src.Card.Brand}, *{src.Card.Last4}, " +
@ -66,12 +66,12 @@ namespace Bit.Core.Models.Business
public BillingSource(Braintree.PaymentMethod method)
{
if(method is Braintree.PayPalAccount paypal)
if (method is Braintree.PayPalAccount paypal)
{
Type = PaymentMethodType.PayPal;
Description = paypal.Email;
}
else if(method is Braintree.CreditCard card)
else if (method is Braintree.CreditCard card)
{
Type = PaymentMethodType.Card;
Description = $"{card.CardType.ToString()}, *{card.LastFour}, " +
@ -81,7 +81,7 @@ namespace Bit.Core.Models.Business
card.ExpirationYear);
CardBrand = card.CardType.ToString();
}
else if(method is Braintree.UsBankAccount bank)
else if (method is Braintree.UsBankAccount bank)
{
Type = PaymentMethodType.BankAccount;
Description = $"{bank.BankName}, *{bank.Last4}";

View File

@ -43,9 +43,9 @@ namespace Bit.Core.Models.Business
UsersGetPremium = org.UsersGetPremium;
Issued = DateTime.UtcNow;
if(subscriptionInfo?.Subscription == null)
if (subscriptionInfo?.Subscription == null)
{
if(org.PlanType == PlanType.Custom && org.ExpirationDate.HasValue)
if (org.PlanType == PlanType.Custom && org.ExpirationDate.HasValue)
{
Expires = Refresh = org.ExpirationDate.Value;
Trial = false;
@ -56,7 +56,7 @@ namespace Bit.Core.Models.Business
Trial = true;
}
}
else if(subscriptionInfo.Subscription.TrialEndDate.HasValue &&
else if (subscriptionInfo.Subscription.TrialEndDate.HasValue &&
subscriptionInfo.Subscription.TrialEndDate.Value > DateTime.UtcNow)
{
Expires = Refresh = subscriptionInfo.Subscription.TrialEndDate.Value;
@ -64,12 +64,12 @@ namespace Bit.Core.Models.Business
}
else
{
if(org.ExpirationDate.HasValue && org.ExpirationDate.Value < DateTime.UtcNow)
if (org.ExpirationDate.HasValue && org.ExpirationDate.Value < DateTime.UtcNow)
{
// expired
Expires = Refresh = org.ExpirationDate.Value;
}
else if(subscriptionInfo?.Subscription?.PeriodDuration != null &&
else if (subscriptionInfo?.Subscription?.PeriodDuration != null &&
subscriptionInfo.Subscription.PeriodDuration > TimeSpan.FromDays(180))
{
Refresh = DateTime.UtcNow.AddDays(30);
@ -122,7 +122,7 @@ namespace Bit.Core.Models.Business
public byte[] GetDataBytes(bool forHash = false)
{
string data = null;
if(Version >= 1 && Version <= 6)
if (Version >= 1 && Version <= 6)
{
var props = typeof(OrganizationLicense)
.GetProperties(BindingFlags.Public | BindingFlags.Instance)
@ -162,7 +162,7 @@ namespace Bit.Core.Models.Business
public byte[] ComputeHash()
{
using(var alg = SHA256.Create())
using (var alg = SHA256.Create())
{
return alg.ComputeHash(GetDataBytes(true));
}
@ -170,12 +170,12 @@ namespace Bit.Core.Models.Business
public bool CanUse(GlobalSettings globalSettings)
{
if(!Enabled || Issued > DateTime.UtcNow || Expires < DateTime.UtcNow)
if (!Enabled || Issued > DateTime.UtcNow || Expires < DateTime.UtcNow)
{
return false;
}
if(Version >= 1 && Version <= 6)
if (Version >= 1 && Version <= 6)
{
return InstallationId == globalSettings.Installation.Id && SelfHost;
}
@ -187,12 +187,12 @@ namespace Bit.Core.Models.Business
public bool VerifyData(Organization organization, GlobalSettings globalSettings)
{
if(Issued > DateTime.UtcNow || Expires < DateTime.UtcNow)
if (Issued > DateTime.UtcNow || Expires < DateTime.UtcNow)
{
return false;
}
if(Version >= 1 && Version <= 6)
if (Version >= 1 && Version <= 6)
{
var valid =
globalSettings.Installation.Id == InstallationId &&
@ -207,27 +207,27 @@ namespace Bit.Core.Models.Business
organization.SelfHost == SelfHost &&
organization.Name.Equals(Name);
if(valid && Version >= 2)
if (valid && Version >= 2)
{
valid = organization.UsersGetPremium == UsersGetPremium;
}
if(valid && Version >= 3)
if (valid && Version >= 3)
{
valid = organization.UseEvents == UseEvents;
}
if(valid && Version >= 4)
if (valid && Version >= 4)
{
valid = organization.Use2fa == Use2fa;
}
if(valid && Version >= 5)
if (valid && Version >= 5)
{
valid = organization.UseApi == UseApi;
}
if(valid && Version >= 6)
if (valid && Version >= 6)
{
valid = organization.UsePolicies == UsePolicies;
}
@ -242,7 +242,7 @@ namespace Bit.Core.Models.Business
public bool VerifySignature(X509Certificate2 certificate)
{
using(var rsa = certificate.GetRSAPublicKey())
using (var rsa = certificate.GetRSAPublicKey())
{
return rsa.VerifyData(GetDataBytes(), SignatureBytes, HashAlgorithmName.SHA256, RSASignaturePadding.Pkcs1);
}
@ -250,12 +250,12 @@ namespace Bit.Core.Models.Business
public byte[] Sign(X509Certificate2 certificate)
{
if(!certificate.HasPrivateKey)
if (!certificate.HasPrivateKey)
{
throw new InvalidOperationException("You don't have the private key!");
}
using(var rsa = certificate.GetRSAPrivateKey())
using (var rsa = certificate.GetRSAPrivateKey())
{
return rsa.SignData(GetDataBytes(), HashAlgorithmName.SHA256, RSASignaturePadding.Pkcs1);
}

View File

@ -23,7 +23,7 @@ namespace Bit.Core.Models.Business
CancelledDate = sub.CanceledAt;
CancelAtEndDate = sub.CancelAtPeriodEnd;
Cancelled = sub.Status == "canceled" || sub.Status == "unpaid" || sub.Status == "incomplete_expired";
if(sub.Items?.Data != null)
if (sub.Items?.Data != null)
{
Items = sub.Items.Data.Select(i => new BillingSubscriptionItem(i));
}
@ -44,7 +44,7 @@ namespace Bit.Core.Models.Business
{
public BillingSubscriptionItem(SubscriptionItem item)
{
if(item.Plan != null)
if (item.Plan != null)
{
Name = item.Plan.Nickname;
Amount = item.Plan.Amount.GetValueOrDefault() / 100M;
@ -74,7 +74,7 @@ namespace Bit.Core.Models.Business
public BillingUpcomingInvoice(Braintree.Subscription sub)
{
Amount = sub.NextBillAmount.GetValueOrDefault() + sub.Balance.GetValueOrDefault();
if(Amount < 0)
if (Amount < 0)
{
Amount = 0;
}

View File

@ -71,7 +71,7 @@ namespace Bit.Core.Models.Business
public byte[] GetDataBytes(bool forHash = false)
{
string data = null;
if(Version == 1)
if (Version == 1)
{
var props = typeof(UserLicense)
.GetProperties(BindingFlags.Public | BindingFlags.Instance)
@ -101,7 +101,7 @@ namespace Bit.Core.Models.Business
public byte[] ComputeHash()
{
using(var alg = SHA256.Create())
using (var alg = SHA256.Create())
{
return alg.ComputeHash(GetDataBytes(true));
}
@ -109,12 +109,12 @@ namespace Bit.Core.Models.Business
public bool CanUse(User user)
{
if(Issued > DateTime.UtcNow || Expires < DateTime.UtcNow)
if (Issued > DateTime.UtcNow || Expires < DateTime.UtcNow)
{
return false;
}
if(Version == 1)
if (Version == 1)
{
return user.EmailVerified && user.Email.Equals(Email, StringComparison.InvariantCultureIgnoreCase);
}
@ -126,12 +126,12 @@ namespace Bit.Core.Models.Business
public bool VerifyData(User user)
{
if(Issued > DateTime.UtcNow || Expires < DateTime.UtcNow)
if (Issued > DateTime.UtcNow || Expires < DateTime.UtcNow)
{
return false;
}
if(Version == 1)
if (Version == 1)
{
return
user.LicenseKey != null && user.LicenseKey.Equals(LicenseKey) &&
@ -146,7 +146,7 @@ namespace Bit.Core.Models.Business
public bool VerifySignature(X509Certificate2 certificate)
{
using(var rsa = certificate.GetRSAPublicKey())
using (var rsa = certificate.GetRSAPublicKey())
{
return rsa.VerifyData(GetDataBytes(), SignatureBytes, HashAlgorithmName.SHA256, RSASignaturePadding.Pkcs1);
}
@ -154,12 +154,12 @@ namespace Bit.Core.Models.Business
public byte[] Sign(X509Certificate2 certificate)
{
if(!certificate.HasPrivateKey)
if (!certificate.HasPrivateKey)
{
throw new InvalidOperationException("You don't have the private key!");
}
using(var rsa = certificate.GetRSAPrivateKey())
using (var rsa = certificate.GetRSAPrivateKey())
{
return rsa.SignData(GetDataBytes(), HashAlgorithmName.SHA256, RSASignaturePadding.Pkcs1);
}