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

@ -15,7 +15,7 @@ namespace Bit.Core.Models.Api
public CipherLoginModel(CipherLoginData data)
{
Uris = data.Uris?.Select(u => new CipherLoginUriModel(u))?.ToList();
if(!Uris?.Any() ?? true)
if (!Uris?.Any() ?? true)
{
Uri = data.Uri;
}
@ -33,12 +33,12 @@ namespace Bit.Core.Models.Api
get => Uris?.FirstOrDefault()?.Uri;
set
{
if(string.IsNullOrWhiteSpace(value))
if (string.IsNullOrWhiteSpace(value))
{
return;
}
if(Uris == null)
if (Uris == null)
{
Uris = new List<CipherLoginUriModel>();
}

View File

@ -12,7 +12,7 @@ namespace Bit.Core.Models.Api.Public
public MemberBaseModel(OrganizationUser user)
{
if(user == null)
if (user == null)
{
throw new ArgumentNullException(nameof(user));
}
@ -24,7 +24,7 @@ namespace Bit.Core.Models.Api.Public
public MemberBaseModel(OrganizationUserUserDetails user)
{
if(user == null)
if (user == null)
{
throw new ArgumentNullException(nameof(user));
}

View File

@ -28,19 +28,19 @@ namespace Bit.Core.Models.Api.Public
public Tuple<DateTime, DateTime> ToDateRange()
{
if(!End.HasValue || !Start.HasValue)
if (!End.HasValue || !Start.HasValue)
{
End = DateTime.UtcNow.Date.AddDays(1).AddMilliseconds(-1);
Start = DateTime.UtcNow.Date.AddDays(-30);
}
else if(Start.Value > End.Value)
else if (Start.Value > End.Value)
{
var newEnd = Start;
Start = End;
End = newEnd;
}
if((End.Value - Start.Value) > TimeSpan.FromDays(367))
if ((End.Value - Start.Value) > TimeSpan.FromDays(367))
{
throw new BadRequestException("Date range must be < 367 days.");
}

View File

@ -22,12 +22,12 @@ namespace Bit.Core.Models.Api.Public
public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
{
if(Email.Contains(" ") || Email.Contains("<"))
if (Email.Contains(" ") || Email.Contains("<"))
{
yield return new ValidationResult($"Email is not valid.",
new string[] { nameof(Email) });
}
else if(Email.Length > 50)
else if (Email.Length > 50)
{
yield return new ValidationResult($"Email is longer than 50 characters.",
new string[] { nameof(Email) });

View File

@ -7,7 +7,7 @@ namespace Bit.Core.Models.Api.Public
{
public AssociationWithPermissionsResponseModel(SelectionReadOnly selection)
{
if(selection == null)
if (selection == null)
{
throw new ArgumentNullException(nameof(selection));
}

View File

@ -14,7 +14,7 @@ namespace Bit.Core.Models.Api.Public
{
public CollectionResponseModel(Collection collection, IEnumerable<SelectionReadOnly> groups)
{
if(collection == null)
if (collection == null)
{
throw new ArgumentNullException(nameof(collection));
}

View File

@ -20,17 +20,17 @@ namespace Bit.Core.Models.Api.Public
var keys = modelState.Keys.ToList();
var values = modelState.Values.ToList();
for(var i = 0; i < values.Count; i++)
for (var i = 0; i < values.Count; i++)
{
var value = values[i];
if(keys.Count <= i)
if (keys.Count <= i)
{
// Keys not available for some reason.
break;
}
var key = keys[i];
if(value.ValidationState != ModelValidationState.Invalid || value.Errors.Count == 0)
if (value.ValidationState != ModelValidationState.Invalid || value.Errors.Count == 0)
{
continue;
}

View File

@ -12,7 +12,7 @@ namespace Bit.Core.Models.Api.Public
{
public EventResponseModel(IEvent ev)
{
if(ev == null)
if (ev == null)
{
throw new ArgumentNullException(nameof(ev));
}

View File

@ -14,7 +14,7 @@ namespace Bit.Core.Models.Api.Public
{
public GroupResponseModel(Group group, IEnumerable<SelectionReadOnly> collections)
{
if(group == null)
if (group == null)
{
throw new ArgumentNullException(nameof(group));
}

View File

@ -16,7 +16,7 @@ namespace Bit.Core.Models.Api.Public
public MemberResponseModel(OrganizationUser user, IEnumerable<SelectionReadOnly> collections)
: base(user)
{
if(user == null)
if (user == null)
{
throw new ArgumentNullException(nameof(user));
}
@ -32,7 +32,7 @@ namespace Bit.Core.Models.Api.Public
IEnumerable<SelectionReadOnly> collections)
: base(user)
{
if(user == null)
if (user == null)
{
throw new ArgumentNullException(nameof(user));
}

View File

@ -13,7 +13,7 @@ namespace Bit.Core.Models.Api.Public
{
public PolicyResponseModel(Policy policy)
{
if(policy == null)
if (policy == null)
{
throw new ArgumentNullException(nameof(policy));
}
@ -21,7 +21,7 @@ namespace Bit.Core.Models.Api.Public
Id = policy.Id;
Type = policy.Type;
Enabled = policy.Enabled;
if(!string.IsNullOrWhiteSpace(policy.Data))
if (!string.IsNullOrWhiteSpace(policy.Data))
{
Data = JsonConvert.DeserializeObject<Dictionary<string, object>>(policy.Data);
}

View File

@ -14,12 +14,12 @@ namespace Bit.Core.Models.Api
public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
{
if(Kdf.HasValue && KdfIterations.HasValue)
if (Kdf.HasValue && KdfIterations.HasValue)
{
switch(Kdf.Value)
switch (Kdf.Value)
{
case KdfType.PBKDF2_SHA256:
if(KdfIterations.Value < 5000 || KdfIterations.Value > 2_000_000)
if (KdfIterations.Value < 5000 || KdfIterations.Value > 2_000_000)
{
yield return new ValidationResult("KDF iterations must be between 5000 and 2000000.");
}

View File

@ -11,12 +11,12 @@ namespace Bit.Core.Models.Api
public User ToUser(User existingUser)
{
if(string.IsNullOrWhiteSpace(existingUser.PublicKey) && !string.IsNullOrWhiteSpace(PublicKey))
if (string.IsNullOrWhiteSpace(existingUser.PublicKey) && !string.IsNullOrWhiteSpace(PublicKey))
{
existingUser.PublicKey = PublicKey;
}
if(string.IsNullOrWhiteSpace(existingUser.PrivateKey))
if (string.IsNullOrWhiteSpace(existingUser.PrivateKey))
{
existingUser.PrivateKey = EncryptedPrivateKey;
}

View File

@ -23,7 +23,7 @@ namespace Bit.Core.Models.Api
public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
{
var creditType = PaymentMethodType.HasValue && PaymentMethodType.Value == Enums.PaymentMethodType.Credit;
if(string.IsNullOrWhiteSpace(PaymentToken) && !creditType && License == null)
if (string.IsNullOrWhiteSpace(PaymentToken) && !creditType && License == null)
{
yield return new ValidationResult("Payment token or license is required.");
}

View File

@ -37,12 +37,12 @@ namespace Bit.Core.Models.Api
KdfIterations = KdfIterations.GetValueOrDefault(5000)
};
if(Key != null)
if (Key != null)
{
user.Key = Key;
}
if(Keys != null)
if (Keys != null)
{
Keys.ToUser(user);
}
@ -52,12 +52,12 @@ namespace Bit.Core.Models.Api
public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
{
if(Kdf.HasValue && KdfIterations.HasValue)
if (Kdf.HasValue && KdfIterations.HasValue)
{
switch(Kdf.Value)
switch (Kdf.Value)
{
case KdfType.PBKDF2_SHA256:
if(KdfIterations.Value < 5000 || KdfIterations.Value > 1_000_000)
if (KdfIterations.Value < 5000 || KdfIterations.Value > 1_000_000)
{
yield return new ValidationResult("KDF iterations must be between 5000 and 1000000.");
}

View File

@ -10,7 +10,7 @@ namespace Bit.Core.Models.Api
public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
{
if(StorageGbAdjustment == 0)
if (StorageGbAdjustment == 0)
{
yield return new ValidationResult("Storage adjustment cannot be 0.",
new string[] { nameof(StorageGbAdjustment) });

View File

@ -33,16 +33,16 @@ namespace Bit.Core.Models.Api
};
var posData = string.Empty;
if(UserId.HasValue)
if (UserId.HasValue)
{
posData = "userId:" + UserId.Value;
}
else if(OrganizationId.HasValue)
else if (OrganizationId.HasValue)
{
posData = "organizationId:" + OrganizationId.Value;
}
if(Credit)
if (Credit)
{
posData += ",accountCredit:1";
inv.ItemDesc = "Bitwarden Account Credit";
@ -58,7 +58,7 @@ namespace Bit.Core.Models.Api
public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
{
if(!UserId.HasValue && !OrganizationId.HasValue)
if (!UserId.HasValue && !OrganizationId.HasValue)
{
yield return new ValidationResult("User or Ooganization is required.");
}

View File

@ -63,7 +63,7 @@ namespace Bit.Core.Models.Api
public Cipher ToCipher(Cipher existingCipher)
{
switch(existingCipher.Type)
switch (existingCipher.Type)
{
case CipherType.Login:
var loginObj = JObject.FromObject(new CipherLoginData(this),
@ -90,29 +90,29 @@ namespace Bit.Core.Models.Api
var hasAttachments2 = (Attachments2?.Count ?? 0) > 0;
var hasAttachments = (Attachments?.Count ?? 0) > 0;
if(!hasAttachments2 && !hasAttachments)
if (!hasAttachments2 && !hasAttachments)
{
return existingCipher;
}
var attachments = existingCipher.GetAttachments();
if((attachments?.Count ?? 0) == 0)
if ((attachments?.Count ?? 0) == 0)
{
return existingCipher;
}
if(hasAttachments2)
if (hasAttachments2)
{
foreach(var attachment in attachments.Where(a => Attachments2.ContainsKey(a.Key)))
foreach (var attachment in attachments.Where(a => Attachments2.ContainsKey(a.Key)))
{
var attachment2 = Attachments2[attachment.Key];
attachment.Value.FileName = attachment2.FileName;
attachment.Value.Key = attachment2.Key;
}
}
else if(hasAttachments)
else if (hasAttachments)
{
foreach(var attachment in attachments.Where(a => Attachments.ContainsKey(a.Key)))
foreach (var attachment in attachments.Where(a => Attachments.ContainsKey(a.Key)))
{
attachment.Value.FileName = Attachments[attachment.Key];
attachment.Value.Key = null;
@ -125,7 +125,7 @@ namespace Bit.Core.Models.Api
public Cipher ToOrganizationCipher()
{
if(string.IsNullOrWhiteSpace(OrganizationId))
if (string.IsNullOrWhiteSpace(OrganizationId))
{
throw new ArgumentNullException(nameof(OrganizationId));
}
@ -162,7 +162,7 @@ namespace Bit.Core.Models.Api
public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
{
if(!string.IsNullOrWhiteSpace(Cipher.OrganizationId) && (!CollectionIds?.Any() ?? true))
if (!string.IsNullOrWhiteSpace(Cipher.OrganizationId) && (!CollectionIds?.Any() ?? true))
{
yield return new ValidationResult("You must select at least one collection.",
new string[] { nameof(CollectionIds) });
@ -179,13 +179,13 @@ namespace Bit.Core.Models.Api
public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
{
if(string.IsNullOrWhiteSpace(Cipher.OrganizationId))
if (string.IsNullOrWhiteSpace(Cipher.OrganizationId))
{
yield return new ValidationResult("Cipher OrganizationId is required.",
new string[] { nameof(Cipher.OrganizationId) });
}
if(!CollectionIds?.Any() ?? true)
if (!CollectionIds?.Any() ?? true)
{
yield return new ValidationResult("You must select at least one collection.",
new string[] { nameof(CollectionIds) });
@ -221,7 +221,7 @@ namespace Bit.Core.Models.Api
public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
{
if(!Ciphers?.Any() ?? true)
if (!Ciphers?.Any() ?? true)
{
yield return new ValidationResult("You must select at least one cipher.",
new string[] { nameof(Ciphers) });
@ -230,27 +230,27 @@ namespace Bit.Core.Models.Api
{
var allHaveIds = true;
var organizationIds = new HashSet<string>();
foreach(var c in Ciphers)
foreach (var c in Ciphers)
{
organizationIds.Add(c.OrganizationId);
if(allHaveIds)
if (allHaveIds)
{
allHaveIds = !(!c.Id.HasValue || string.IsNullOrWhiteSpace(c.OrganizationId));
}
}
if(!allHaveIds)
if (!allHaveIds)
{
yield return new ValidationResult("All Ciphers must have an Id and OrganizationId.",
new string[] { nameof(Ciphers) });
}
else if(organizationIds.Count != 1)
else if (organizationIds.Count != 1)
{
yield return new ValidationResult("All ciphers must be for the same organization.");
}
}
if(!CollectionIds?.Any() ?? true)
if (!CollectionIds?.Any() ?? true)
{
yield return new ValidationResult("You must select at least one collection.",
new string[] { nameof(CollectionIds) });

View File

@ -11,7 +11,7 @@ namespace Bit.Core.Models.Api
public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
{
if(PaymentMethodType != Enums.PaymentMethodType.AppleInApp)
if (PaymentMethodType != Enums.PaymentMethodType.AppleInApp)
{
yield return new ValidationResult("Not a supported in-app purchase payment method.",
new string[] { nameof(PaymentMethodType) });

View File

@ -62,7 +62,7 @@ namespace Bit.Core.Models.Api
public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
{
if(string.IsNullOrWhiteSpace(Email) && !Deleted)
if (string.IsNullOrWhiteSpace(Email) && !Deleted)
{
yield return new ValidationResult("Email is required for enabled users.", new string[] { nameof(Email) });
}

View File

@ -53,11 +53,11 @@ namespace Bit.Core.Models.Api
public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
{
if(PlanType != PlanType.Free && string.IsNullOrWhiteSpace(PaymentToken))
if (PlanType != PlanType.Free && string.IsNullOrWhiteSpace(PaymentToken))
{
yield return new ValidationResult("Payment required.", new string[] { nameof(PaymentToken) });
}
if(PlanType != PlanType.Free && !PaymentMethodType.HasValue)
if (PlanType != PlanType.Free && !PaymentMethodType.HasValue)
{
yield return new ValidationResult("Payment method type required.",
new string[] { nameof(PaymentMethodType) });

View File

@ -11,7 +11,7 @@ namespace Bit.Core.Models.Api
public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
{
if(SeatAdjustment == 0)
if (SeatAdjustment == 0)
{
yield return new ValidationResult("Seat adjustment cannot be 0.", new string[] { nameof(SeatAdjustment) });
}

View File

@ -17,26 +17,26 @@ namespace Bit.Core.Models.Api
public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
{
if(!Emails.Any())
if (!Emails.Any())
{
yield return new ValidationResult("An email is required.");
}
if(Emails.Count() > 20)
if (Emails.Count() > 20)
{
yield return new ValidationResult("You can only invite up to 20 users at a time.");
}
var attr = new EmailAddressAttribute();
for(var i = 0; i < Emails.Count(); i++)
for (var i = 0; i < Emails.Count(); i++)
{
var email = Emails.ElementAt(i);
if(!attr.IsValid(email) || email.Contains(" ") || email.Contains("<"))
if (!attr.IsValid(email) || email.Contains(" ") || email.Contains("<"))
{
yield return new ValidationResult($"Email #{i + 1} is not valid.",
new string[] { nameof(Emails) });
}
else if(email.Length > 50)
else if (email.Length > 50)
{
yield return new ValidationResult($"Email #{i + 1} is longer than 50 characters.",
new string[] { nameof(Emails) });

View File

@ -17,7 +17,7 @@ namespace Bit.Core.Models.Api
public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
{
if(string.IsNullOrWhiteSpace(UserId) && string.IsNullOrWhiteSpace(OrganizationId))
if (string.IsNullOrWhiteSpace(UserId) && string.IsNullOrWhiteSpace(OrganizationId))
{
yield return new ValidationResult($"{nameof(UserId)} or {nameof(OrganizationId)} is required.");
}

View File

@ -18,11 +18,11 @@ namespace Bit.Core.Models.Api
public User ToUser(User extistingUser)
{
var providers = extistingUser.GetTwoFactorProviders();
if(providers == null)
if (providers == null)
{
providers = new Dictionary<TwoFactorProviderType, TwoFactorProvider>();
}
else if(providers.ContainsKey(TwoFactorProviderType.Authenticator))
else if (providers.ContainsKey(TwoFactorProviderType.Authenticator))
{
providers.Remove(TwoFactorProviderType.Authenticator);
}
@ -52,11 +52,11 @@ namespace Bit.Core.Models.Api
public User ToUser(User extistingUser)
{
var providers = extistingUser.GetTwoFactorProviders();
if(providers == null)
if (providers == null)
{
providers = new Dictionary<TwoFactorProviderType, TwoFactorProvider>();
}
else if(providers.ContainsKey(TwoFactorProviderType.Duo))
else if (providers.ContainsKey(TwoFactorProviderType.Duo))
{
providers.Remove(TwoFactorProviderType.Duo);
}
@ -78,11 +78,11 @@ namespace Bit.Core.Models.Api
public Organization ToOrganization(Organization extistingOrg)
{
var providers = extistingOrg.GetTwoFactorProviders();
if(providers == null)
if (providers == null)
{
providers = new Dictionary<TwoFactorProviderType, TwoFactorProvider>();
}
else if(providers.ContainsKey(TwoFactorProviderType.OrganizationDuo))
else if (providers.ContainsKey(TwoFactorProviderType.OrganizationDuo))
{
providers.Remove(TwoFactorProviderType.OrganizationDuo);
}
@ -103,7 +103,7 @@ namespace Bit.Core.Models.Api
public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
{
if(!Host.StartsWith("api-") || !Host.EndsWith(".duosecurity.com"))
if (!Host.StartsWith("api-") || !Host.EndsWith(".duosecurity.com"))
{
yield return new ValidationResult("Host is invalid.", new string[] { nameof(Host) });
}
@ -123,11 +123,11 @@ namespace Bit.Core.Models.Api
public User ToUser(User extistingUser)
{
var providers = extistingUser.GetTwoFactorProviders();
if(providers == null)
if (providers == null)
{
providers = new Dictionary<TwoFactorProviderType, TwoFactorProvider>();
}
else if(providers.ContainsKey(TwoFactorProviderType.YubiKey))
else if (providers.ContainsKey(TwoFactorProviderType.YubiKey))
{
providers.Remove(TwoFactorProviderType.YubiKey);
}
@ -151,7 +151,7 @@ namespace Bit.Core.Models.Api
private string FormatKey(string keyValue)
{
if(string.IsNullOrWhiteSpace(keyValue))
if (string.IsNullOrWhiteSpace(keyValue))
{
return null;
}
@ -161,33 +161,33 @@ namespace Bit.Core.Models.Api
public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
{
if(string.IsNullOrWhiteSpace(Key1) && string.IsNullOrWhiteSpace(Key2) && string.IsNullOrWhiteSpace(Key3) &&
if (string.IsNullOrWhiteSpace(Key1) && string.IsNullOrWhiteSpace(Key2) && string.IsNullOrWhiteSpace(Key3) &&
string.IsNullOrWhiteSpace(Key4) && string.IsNullOrWhiteSpace(Key5))
{
yield return new ValidationResult("A key is required.", new string[] { nameof(Key1) });
}
if(!string.IsNullOrWhiteSpace(Key1) && Key1.Length < 12)
if (!string.IsNullOrWhiteSpace(Key1) && Key1.Length < 12)
{
yield return new ValidationResult("Key 1 in invalid.", new string[] { nameof(Key1) });
}
if(!string.IsNullOrWhiteSpace(Key2) && Key2.Length < 12)
if (!string.IsNullOrWhiteSpace(Key2) && Key2.Length < 12)
{
yield return new ValidationResult("Key 2 in invalid.", new string[] { nameof(Key2) });
}
if(!string.IsNullOrWhiteSpace(Key3) && Key3.Length < 12)
if (!string.IsNullOrWhiteSpace(Key3) && Key3.Length < 12)
{
yield return new ValidationResult("Key 3 in invalid.", new string[] { nameof(Key3) });
}
if(!string.IsNullOrWhiteSpace(Key4) && Key4.Length < 12)
if (!string.IsNullOrWhiteSpace(Key4) && Key4.Length < 12)
{
yield return new ValidationResult("Key 4 in invalid.", new string[] { nameof(Key4) });
}
if(!string.IsNullOrWhiteSpace(Key5) && Key5.Length < 12)
if (!string.IsNullOrWhiteSpace(Key5) && Key5.Length < 12)
{
yield return new ValidationResult("Key 5 in invalid.", new string[] { nameof(Key5) });
}
@ -204,11 +204,11 @@ namespace Bit.Core.Models.Api
public User ToUser(User extistingUser)
{
var providers = extistingUser.GetTwoFactorProviders();
if(providers == null)
if (providers == null)
{
providers = new Dictionary<TwoFactorProviderType, TwoFactorProvider>();
}
else if(providers.ContainsKey(TwoFactorProviderType.Email))
else if (providers.ContainsKey(TwoFactorProviderType.Email))
{
providers.Remove(TwoFactorProviderType.Email);
}
@ -237,7 +237,7 @@ namespace Bit.Core.Models.Api
public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
{
if(!Id.HasValue || Id < 0 || Id > 5)
if (!Id.HasValue || Id < 0 || Id > 5)
{
yield return new ValidationResult("Invalid Key Id", new string[] { nameof(Id) });
}

View File

@ -8,7 +8,7 @@ namespace Bit.Core.Models.Api
public ApiKeyResponseModel(Organization organization, string obj = "apiKey")
: base(obj)
{
if(organization == null)
if (organization == null)
{
throw new ArgumentNullException(nameof(organization));
}

View File

@ -29,7 +29,7 @@ namespace Bit.Core.Models.Api
public static IEnumerable<AttachmentResponseModel> FromCipher(Cipher cipher, GlobalSettings globalSettings)
{
var attachments = cipher.GetAttachments();
if(attachments == null)
if (attachments == null)
{
return null;
}

View File

@ -13,7 +13,7 @@ namespace Bit.Core.Models.Api
public CipherMiniResponseModel(Cipher cipher, GlobalSettings globalSettings, bool orgUseTotp, string obj = "cipherMini")
: base(obj)
{
if(cipher == null)
if (cipher == null)
{
throw new ArgumentNullException(nameof(cipher));
}
@ -22,7 +22,7 @@ namespace Bit.Core.Models.Api
Type = cipher.Type;
CipherData cipherData;
switch(cipher.Type)
switch (cipher.Type)
{
case Enums.CipherType.Login:
var loginData = JsonConvert.DeserializeObject<CipherLoginData>(cipher.Data);
@ -100,7 +100,7 @@ namespace Bit.Core.Models.Api
IDictionary<Guid, IGrouping<Guid, CollectionCipher>> collectionCiphers, string obj = "cipherDetails")
: base(cipher, globalSettings, obj)
{
if(collectionCiphers?.ContainsKey(cipher.Id) ?? false)
if (collectionCiphers?.ContainsKey(cipher.Id) ?? false)
{
CollectionIds = collectionCiphers[cipher.Id].Select(c => c.CollectionId);
}
@ -126,7 +126,7 @@ namespace Bit.Core.Models.Api
IDictionary<Guid, IGrouping<Guid, CollectionCipher>> collectionCiphers, string obj = "cipherMiniDetails")
: base(cipher, globalSettings, false, obj)
{
if(collectionCiphers?.ContainsKey(cipher.Id) ?? false)
if (collectionCiphers?.ContainsKey(cipher.Id) ?? false)
{
CollectionIds = collectionCiphers[cipher.Id].Select(c => c.CollectionId);
}

View File

@ -11,7 +11,7 @@ namespace Bit.Core.Models.Api
public CollectionResponseModel(Collection collection, string obj = "collection")
: base(obj)
{
if(collection == null)
if (collection == null)
{
throw new ArgumentNullException(nameof(collection));
}

View File

@ -9,7 +9,7 @@ namespace Bit.Core.Models.Api
public DeviceResponseModel(Device device)
: base("device")
{
if(device == null)
if (device == null)
{
throw new ArgumentNullException(nameof(device));
}

View File

@ -12,7 +12,7 @@ namespace Bit.Core.Models.Api
public DomainsResponseModel(User user, bool excluded = true)
: base("domains")
{
if(user == null)
if (user == null)
{
throw new ArgumentNullException(nameof(user));
}
@ -26,7 +26,7 @@ namespace Bit.Core.Models.Api
var globalDomains = new List<GlobalDomains>();
var domainsToInclude = excluded ? Core.Utilities.StaticStore.GlobalDomains :
Core.Utilities.StaticStore.GlobalDomains.Where(d => !excludedGlobalEquivalentDomains.Contains(d.Key));
foreach(var domain in domainsToInclude)
foreach (var domain in domainsToInclude)
{
globalDomains.Add(new GlobalDomains(domain.Key, domain.Value, excludedGlobalEquivalentDomains, excluded));
}

View File

@ -25,11 +25,11 @@ namespace Bit.Core.Models.Api
var keys = modelState.Keys.ToList();
var values = modelState.Values.ToList();
for(var i = 0; i < values.Count; i++)
for (var i = 0; i < values.Count; i++)
{
var value = values[i];
if(keys.Count <= i)
if (keys.Count <= i)
{
// Keys not available for some reason.
break;
@ -37,7 +37,7 @@ namespace Bit.Core.Models.Api
var key = keys[i];
if(value.ValidationState != ModelValidationState.Invalid || value.Errors.Count == 0)
if (value.ValidationState != ModelValidationState.Invalid || value.Errors.Count == 0)
{
continue;
}

View File

@ -9,7 +9,7 @@ namespace Bit.Core.Models.Api
public EventResponseModel(IEvent ev)
: base("event")
{
if(ev == null)
if (ev == null)
{
throw new ArgumentNullException(nameof(ev));
}

View File

@ -8,7 +8,7 @@ namespace Bit.Core.Models.Api
public FolderResponseModel(Folder folder)
: base("folder")
{
if(folder == null)
if (folder == null)
{
throw new ArgumentNullException(nameof(folder));
}

View File

@ -11,7 +11,7 @@ namespace Bit.Core.Models.Api
public GroupResponseModel(Group group, string obj = "group")
: base(obj)
{
if(group == null)
if (group == null)
{
throw new ArgumentNullException(nameof(group));
}

View File

@ -8,7 +8,7 @@ namespace Bit.Core.Models.Api
public KeysResponseModel(User user)
: base("keys")
{
if(user == null)
if (user == null)
{
throw new ArgumentNullException(nameof(user));
}

View File

@ -11,7 +11,7 @@ namespace Bit.Core.Models.Api
public OrganizationResponseModel(Organization organization, string obj = "organization")
: base(obj)
{
if(organization == null)
if (organization == null)
{
throw new ArgumentNullException(nameof(organization));
}
@ -71,7 +71,7 @@ namespace Bit.Core.Models.Api
public OrganizationSubscriptionResponseModel(Organization organization, SubscriptionInfo subscription = null)
: base(organization, "organizationSubscription")
{
if(subscription != null)
if (subscription != null)
{
Subscription = subscription.Subscription != null ?
new BillingSubscription(subscription.Subscription) : null;

View File

@ -12,7 +12,7 @@ namespace Bit.Core.Models.Api
public OrganizationUserResponseModel(OrganizationUser organizationUser, string obj = "organizationUser")
: base(obj)
{
if(organizationUser == null)
if (organizationUser == null)
{
throw new ArgumentNullException(nameof(organizationUser));
}
@ -27,7 +27,7 @@ namespace Bit.Core.Models.Api
public OrganizationUserResponseModel(OrganizationUserUserDetails organizationUser, string obj = "organizationUser")
: base(obj)
{
if(organizationUser == null)
if (organizationUser == null)
{
throw new ArgumentNullException(nameof(organizationUser));
}
@ -64,7 +64,7 @@ namespace Bit.Core.Models.Api
bool twoFactorEnabled, string obj = "organizationUserUserDetails")
: base(organizationUser, obj)
{
if(organizationUser == null)
if (organizationUser == null)
{
throw new ArgumentNullException(nameof(organizationUser));
}

View File

@ -11,7 +11,7 @@ namespace Bit.Core.Models.Api
public PolicyResponseModel(Policy policy, string obj = "policy")
: base(obj)
{
if(policy == null)
if (policy == null)
{
throw new ArgumentNullException(nameof(policy));
}
@ -20,7 +20,7 @@ namespace Bit.Core.Models.Api
OrganizationId = policy.OrganizationId.ToString();
Type = policy.Type;
Enabled = policy.Enabled;
if(!string.IsNullOrWhiteSpace(policy.Data))
if (!string.IsNullOrWhiteSpace(policy.Data))
{
Data = JsonConvert.DeserializeObject<Dictionary<string, object>>(policy.Data);
}

View File

@ -13,7 +13,7 @@ namespace Bit.Core.Models.Api
IEnumerable<OrganizationUserOrganizationDetails> organizationsUserDetails, bool twoFactorEnabled)
: base("profile")
{
if(user == null)
if (user == null)
{
throw new ArgumentNullException(nameof(user));
}

View File

@ -7,7 +7,7 @@ namespace Bit.Core.Models.Api
{
public ResponseModel(string obj)
{
if(string.IsNullOrWhiteSpace(obj))
if (string.IsNullOrWhiteSpace(obj))
{
throw new ArgumentNullException(nameof(obj));
}

View File

@ -7,7 +7,7 @@ namespace Bit.Core.Models.Api
{
public SelectionReadOnlyResponseModel(SelectionReadOnly selection)
{
if(selection == null)
if (selection == null)
{
throw new ArgumentNullException(nameof(selection));
}

View File

@ -30,7 +30,7 @@ namespace Bit.Core.Models.Api
MaxStorageGb = user.MaxStorageGb;
Expiration = user.PremiumExpirationDate;
if(license != null)
if (license != null)
{
License = license;
}
@ -58,7 +58,7 @@ namespace Bit.Core.Models.Api
CancelledDate = sub.CancelledDate;
CancelAtEndDate = sub.CancelAtEndDate;
Cancelled = sub.Cancelled;
if(sub.Items != null)
if (sub.Items != null)
{
Items = sub.Items.Select(i => new BillingSubscriptionItem(i));
}

View File

@ -10,13 +10,13 @@ namespace Bit.Core.Models.Api
public TwoFactorAuthenticatorResponseModel(User user)
: base("twoFactorAuthenticator")
{
if(user == null)
if (user == null)
{
throw new ArgumentNullException(nameof(user));
}
var provider = user.GetTwoFactorProvider(TwoFactorProviderType.Authenticator);
if(provider?.MetaData?.ContainsKey("Key") ?? false)
if (provider?.MetaData?.ContainsKey("Key") ?? false)
{
Key = (string)provider.MetaData["Key"];
Enabled = provider.Enabled;

View File

@ -11,7 +11,7 @@ namespace Bit.Core.Models.Api
public TwoFactorDuoResponseModel(User user)
: base(ResponseObj)
{
if(user == null)
if (user == null)
{
throw new ArgumentNullException(nameof(user));
}
@ -23,7 +23,7 @@ namespace Bit.Core.Models.Api
public TwoFactorDuoResponseModel(Organization org)
: base(ResponseObj)
{
if(org == null)
if (org == null)
{
throw new ArgumentNullException(nameof(org));
}
@ -39,19 +39,19 @@ namespace Bit.Core.Models.Api
private void Build(TwoFactorProvider provider)
{
if(provider?.MetaData != null && provider.MetaData.Count > 0)
if (provider?.MetaData != null && provider.MetaData.Count > 0)
{
Enabled = provider.Enabled;
if(provider.MetaData.ContainsKey("Host"))
if (provider.MetaData.ContainsKey("Host"))
{
Host = (string)provider.MetaData["Host"];
}
if(provider.MetaData.ContainsKey("SKey"))
if (provider.MetaData.ContainsKey("SKey"))
{
SecretKey = (string)provider.MetaData["SKey"];
}
if(provider.MetaData.ContainsKey("IKey"))
if (provider.MetaData.ContainsKey("IKey"))
{
IntegrationKey = (string)provider.MetaData["IKey"];
}

View File

@ -9,13 +9,13 @@ namespace Bit.Core.Models.Api
public TwoFactorEmailResponseModel(User user)
: base("twoFactorEmail")
{
if(user == null)
if (user == null)
{
throw new ArgumentNullException(nameof(user));
}
var provider = user.GetTwoFactorProvider(TwoFactorProviderType.Email);
if(provider?.MetaData?.ContainsKey("Email") ?? false)
if (provider?.MetaData?.ContainsKey("Email") ?? false)
{
Email = (string)provider.MetaData["Email"];
Enabled = provider.Enabled;

View File

@ -11,7 +11,7 @@ namespace Bit.Core.Models.Api
public TwoFactorProviderResponseModel(TwoFactorProviderType type, TwoFactorProvider provider)
: base(ResponseObj)
{
if(provider == null)
if (provider == null)
{
throw new ArgumentNullException(nameof(provider));
}
@ -23,7 +23,7 @@ namespace Bit.Core.Models.Api
public TwoFactorProviderResponseModel(TwoFactorProviderType type, User user)
: base(ResponseObj)
{
if(user == null)
if (user == null)
{
throw new ArgumentNullException(nameof(user));
}
@ -36,7 +36,7 @@ namespace Bit.Core.Models.Api
public TwoFactorProviderResponseModel(TwoFactorProviderType type, Organization organization)
: base(ResponseObj)
{
if(organization == null)
if (organization == null)
{
throw new ArgumentNullException(nameof(organization));
}

View File

@ -8,7 +8,7 @@ namespace Bit.Core.Models.Api
public TwoFactorRecoverResponseModel(User user)
: base("twoFactorRecover")
{
if(user == null)
if (user == null)
{
throw new ArgumentNullException(nameof(user));
}

View File

@ -12,7 +12,7 @@ namespace Bit.Core.Models.Api
public TwoFactorU2fResponseModel(User user)
: base("twoFactorU2f")
{
if(user == null)
if (user == null)
{
throw new ArgumentNullException(nameof(user));
}

View File

@ -9,37 +9,37 @@ namespace Bit.Core.Models.Api
public TwoFactorYubiKeyResponseModel(User user)
: base("twoFactorYubiKey")
{
if(user == null)
if (user == null)
{
throw new ArgumentNullException(nameof(user));
}
var provider = user.GetTwoFactorProvider(TwoFactorProviderType.YubiKey);
if(provider?.MetaData != null && provider.MetaData.Count > 0)
if (provider?.MetaData != null && provider.MetaData.Count > 0)
{
Enabled = provider.Enabled;
if(provider.MetaData.ContainsKey("Key1"))
if (provider.MetaData.ContainsKey("Key1"))
{
Key1 = (string)provider.MetaData["Key1"];
}
if(provider.MetaData.ContainsKey("Key2"))
if (provider.MetaData.ContainsKey("Key2"))
{
Key2 = (string)provider.MetaData["Key2"];
}
if(provider.MetaData.ContainsKey("Key3"))
if (provider.MetaData.ContainsKey("Key3"))
{
Key3 = (string)provider.MetaData["Key3"];
}
if(provider.MetaData.ContainsKey("Key4"))
if (provider.MetaData.ContainsKey("Key4"))
{
Key4 = (string)provider.MetaData["Key4"];
}
if(provider.MetaData.ContainsKey("Key5"))
if (provider.MetaData.ContainsKey("Key5"))
{
Key5 = (string)provider.MetaData["Key5"];
}
if(provider.MetaData.ContainsKey("Nfc"))
if (provider.MetaData.ContainsKey("Nfc"))
{
Nfc = (bool)provider.MetaData["Nfc"];
}