mirror of
https://github.com/bitwarden/server.git
synced 2025-07-01 08:02:49 -05:00
Changed all C# control flow block statements to include space between keyword and open paren
This commit is contained in:
@ -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>();
|
||||
}
|
||||
|
@ -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));
|
||||
}
|
||||
|
@ -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.");
|
||||
}
|
||||
|
@ -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) });
|
||||
|
@ -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));
|
||||
}
|
||||
|
@ -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));
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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));
|
||||
}
|
||||
|
@ -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));
|
||||
}
|
||||
|
@ -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));
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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.");
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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.");
|
||||
}
|
||||
|
@ -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.");
|
||||
}
|
||||
|
@ -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) });
|
||||
|
@ -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.");
|
||||
}
|
||||
|
@ -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) });
|
||||
|
@ -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) });
|
||||
|
@ -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) });
|
||||
}
|
||||
|
@ -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) });
|
||||
|
@ -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) });
|
||||
}
|
||||
|
@ -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) });
|
||||
|
@ -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.");
|
||||
}
|
||||
|
@ -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) });
|
||||
}
|
||||
|
@ -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));
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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));
|
||||
}
|
||||
|
@ -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));
|
||||
}
|
||||
|
@ -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));
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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));
|
||||
}
|
||||
|
@ -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));
|
||||
}
|
||||
|
@ -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));
|
||||
}
|
||||
|
@ -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));
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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));
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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));
|
||||
}
|
||||
|
@ -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));
|
||||
}
|
||||
|
@ -7,7 +7,7 @@ namespace Bit.Core.Models.Api
|
||||
{
|
||||
public SelectionReadOnlyResponseModel(SelectionReadOnly selection)
|
||||
{
|
||||
if(selection == null)
|
||||
if (selection == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(selection));
|
||||
}
|
||||
|
@ -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));
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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"];
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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));
|
||||
}
|
||||
|
@ -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));
|
||||
}
|
||||
|
@ -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));
|
||||
}
|
||||
|
@ -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"];
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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}";
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -44,7 +44,7 @@ namespace Bit.Core.Models.Data
|
||||
var result = base.WriteEntity(operationContext);
|
||||
|
||||
var typeName = nameof(Type);
|
||||
if(result.ContainsKey(typeName))
|
||||
if (result.ContainsKey(typeName))
|
||||
{
|
||||
result[typeName] = new EntityProperty((int)Type);
|
||||
}
|
||||
@ -54,7 +54,7 @@ namespace Bit.Core.Models.Data
|
||||
}
|
||||
|
||||
var deviceTypeName = nameof(DeviceType);
|
||||
if(result.ContainsKey(deviceTypeName))
|
||||
if (result.ContainsKey(deviceTypeName))
|
||||
{
|
||||
result[deviceTypeName] = new EntityProperty((int?)DeviceType);
|
||||
}
|
||||
@ -72,13 +72,13 @@ namespace Bit.Core.Models.Data
|
||||
base.ReadEntity(properties, operationContext);
|
||||
|
||||
var typeName = nameof(Type);
|
||||
if(properties.ContainsKey(typeName) && properties[typeName].Int32Value.HasValue)
|
||||
if (properties.ContainsKey(typeName) && properties[typeName].Int32Value.HasValue)
|
||||
{
|
||||
Type = (EventType)properties[typeName].Int32Value.Value;
|
||||
}
|
||||
|
||||
var deviceTypeName = nameof(DeviceType);
|
||||
if(properties.ContainsKey(deviceTypeName) && properties[deviceTypeName].Int32Value.HasValue)
|
||||
if (properties.ContainsKey(deviceTypeName) && properties[deviceTypeName].Int32Value.HasValue)
|
||||
{
|
||||
DeviceType = (DeviceType)properties[deviceTypeName].Int32Value.Value;
|
||||
}
|
||||
@ -99,7 +99,7 @@ namespace Bit.Core.Models.Data
|
||||
}
|
||||
};
|
||||
|
||||
if(e.OrganizationId.HasValue && e.ActingUserId.HasValue)
|
||||
if (e.OrganizationId.HasValue && e.ActingUserId.HasValue)
|
||||
{
|
||||
entities.Add(new EventTableEntity(e)
|
||||
{
|
||||
@ -109,7 +109,7 @@ namespace Bit.Core.Models.Data
|
||||
});
|
||||
}
|
||||
|
||||
if(e.CipherId.HasValue)
|
||||
if (e.CipherId.HasValue)
|
||||
{
|
||||
entities.Add(new EventTableEntity(e)
|
||||
{
|
||||
|
@ -16,11 +16,11 @@ namespace Bit.Core.Models.Data
|
||||
public InstallationDeviceEntity(string prefixedDeviceId)
|
||||
{
|
||||
var parts = prefixedDeviceId.Split("_");
|
||||
if(parts.Length < 2)
|
||||
if (parts.Length < 2)
|
||||
{
|
||||
throw new ArgumentException("Not enough parts.");
|
||||
}
|
||||
if(!Guid.TryParse(parts[0], out var installationId) || !Guid.TryParse(parts[1], out var deviceId))
|
||||
if (!Guid.TryParse(parts[0], out var installationId) || !Guid.TryParse(parts[1], out var deviceId))
|
||||
{
|
||||
throw new ArgumentException("Could not parse parts.");
|
||||
}
|
||||
|
@ -23,14 +23,14 @@ namespace Bit.Core.Models.Data
|
||||
|
||||
public Dictionary<TwoFactorProviderType, TwoFactorProvider> GetTwoFactorProviders()
|
||||
{
|
||||
if(string.IsNullOrWhiteSpace(TwoFactorProviders))
|
||||
if (string.IsNullOrWhiteSpace(TwoFactorProviders))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
if(_twoFactorProviders == null)
|
||||
if (_twoFactorProviders == null)
|
||||
{
|
||||
_twoFactorProviders =
|
||||
JsonConvert.DeserializeObject<Dictionary<TwoFactorProviderType, TwoFactorProvider>>(
|
||||
@ -39,7 +39,7 @@ namespace Bit.Core.Models.Data
|
||||
|
||||
return _twoFactorProviders;
|
||||
}
|
||||
catch(JsonSerializationException)
|
||||
catch (JsonSerializationException)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
@ -10,7 +10,7 @@ namespace Bit.Core.Models.Mail
|
||||
{
|
||||
get
|
||||
{
|
||||
if(Uri.TryCreate(WebVaultUrl, UriKind.Absolute, out Uri uri))
|
||||
if (Uri.TryCreate(WebVaultUrl, UriKind.Absolute, out Uri uri))
|
||||
{
|
||||
return uri.Host;
|
||||
}
|
||||
|
@ -28,12 +28,12 @@ namespace Bit.Core.Models.Table
|
||||
|
||||
public Dictionary<string, CipherAttachment.MetaData> GetAttachments()
|
||||
{
|
||||
if(string.IsNullOrWhiteSpace(Attachments))
|
||||
if (string.IsNullOrWhiteSpace(Attachments))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
if(_attachmentData != null)
|
||||
if (_attachmentData != null)
|
||||
{
|
||||
return _attachmentData;
|
||||
}
|
||||
@ -51,7 +51,7 @@ namespace Bit.Core.Models.Table
|
||||
|
||||
public void SetAttachments(Dictionary<string, CipherAttachment.MetaData> data)
|
||||
{
|
||||
if(data == null || data.Count == 0)
|
||||
if (data == null || data.Count == 0)
|
||||
{
|
||||
_attachmentData = null;
|
||||
Attachments = null;
|
||||
@ -65,7 +65,7 @@ namespace Bit.Core.Models.Table
|
||||
public void AddAttachment(string id, CipherAttachment.MetaData data)
|
||||
{
|
||||
var attachments = GetAttachments();
|
||||
if(attachments == null)
|
||||
if (attachments == null)
|
||||
{
|
||||
attachments = new Dictionary<string, CipherAttachment.MetaData>();
|
||||
}
|
||||
@ -77,7 +77,7 @@ namespace Bit.Core.Models.Table
|
||||
public void DeleteAttachment(string id)
|
||||
{
|
||||
var attachments = GetAttachments();
|
||||
if(!attachments?.ContainsKey(id) ?? true)
|
||||
if (!attachments?.ContainsKey(id) ?? true)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
@ -48,7 +48,7 @@ namespace Bit.Core.Models.Table
|
||||
|
||||
public void SetNewId()
|
||||
{
|
||||
if(Id == default(Guid))
|
||||
if (Id == default(Guid))
|
||||
{
|
||||
Id = CoreHelpers.GenerateComb();
|
||||
}
|
||||
@ -86,7 +86,7 @@ namespace Bit.Core.Models.Table
|
||||
|
||||
public long StorageBytesRemaining()
|
||||
{
|
||||
if(!MaxStorageGb.HasValue)
|
||||
if (!MaxStorageGb.HasValue)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
@ -97,7 +97,7 @@ namespace Bit.Core.Models.Table
|
||||
public long StorageBytesRemaining(short maxStorageGb)
|
||||
{
|
||||
var maxStorageBytes = maxStorageGb * 1073741824L;
|
||||
if(!Storage.HasValue)
|
||||
if (!Storage.HasValue)
|
||||
{
|
||||
return maxStorageBytes;
|
||||
}
|
||||
@ -107,14 +107,14 @@ namespace Bit.Core.Models.Table
|
||||
|
||||
public Dictionary<TwoFactorProviderType, TwoFactorProvider> GetTwoFactorProviders()
|
||||
{
|
||||
if(string.IsNullOrWhiteSpace(TwoFactorProviders))
|
||||
if (string.IsNullOrWhiteSpace(TwoFactorProviders))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
if(_twoFactorProviders == null)
|
||||
if (_twoFactorProviders == null)
|
||||
{
|
||||
_twoFactorProviders =
|
||||
JsonConvert.DeserializeObject<Dictionary<TwoFactorProviderType, TwoFactorProvider>>(
|
||||
@ -123,7 +123,7 @@ namespace Bit.Core.Models.Table
|
||||
|
||||
return _twoFactorProviders;
|
||||
}
|
||||
catch(JsonSerializationException)
|
||||
catch (JsonSerializationException)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
@ -131,7 +131,7 @@ namespace Bit.Core.Models.Table
|
||||
|
||||
public void SetTwoFactorProviders(Dictionary<TwoFactorProviderType, TwoFactorProvider> providers)
|
||||
{
|
||||
if(!providers.Any())
|
||||
if (!providers.Any())
|
||||
{
|
||||
TwoFactorProviders = null;
|
||||
_twoFactorProviders = null;
|
||||
@ -148,7 +148,7 @@ namespace Bit.Core.Models.Table
|
||||
public bool TwoFactorProviderIsEnabled(TwoFactorProviderType provider)
|
||||
{
|
||||
var providers = GetTwoFactorProviders();
|
||||
if(providers == null || !providers.ContainsKey(provider))
|
||||
if (providers == null || !providers.ContainsKey(provider))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@ -159,7 +159,7 @@ namespace Bit.Core.Models.Table
|
||||
public bool TwoFactorIsEnabled()
|
||||
{
|
||||
var providers = GetTwoFactorProviders();
|
||||
if(providers == null)
|
||||
if (providers == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@ -170,7 +170,7 @@ namespace Bit.Core.Models.Table
|
||||
public TwoFactorProvider GetTwoFactorProvider(TwoFactorProviderType provider)
|
||||
{
|
||||
var providers = GetTwoFactorProviders();
|
||||
if(providers == null || !providers.ContainsKey(provider))
|
||||
if (providers == null || !providers.ContainsKey(provider))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
@ -80,14 +80,14 @@ namespace Bit.Core.Models.Table
|
||||
|
||||
public Dictionary<TwoFactorProviderType, TwoFactorProvider> GetTwoFactorProviders()
|
||||
{
|
||||
if(string.IsNullOrWhiteSpace(TwoFactorProviders))
|
||||
if (string.IsNullOrWhiteSpace(TwoFactorProviders))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
if(_twoFactorProviders == null)
|
||||
if (_twoFactorProviders == null)
|
||||
{
|
||||
_twoFactorProviders =
|
||||
JsonConvert.DeserializeObject<Dictionary<TwoFactorProviderType, TwoFactorProvider>>(
|
||||
@ -96,7 +96,7 @@ namespace Bit.Core.Models.Table
|
||||
|
||||
return _twoFactorProviders;
|
||||
}
|
||||
catch(JsonSerializationException)
|
||||
catch (JsonSerializationException)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
@ -124,7 +124,7 @@ namespace Bit.Core.Models.Table
|
||||
public TwoFactorProvider GetTwoFactorProvider(TwoFactorProviderType provider)
|
||||
{
|
||||
var providers = GetTwoFactorProviders();
|
||||
if(providers == null || !providers.ContainsKey(provider))
|
||||
if (providers == null || !providers.ContainsKey(provider))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
@ -134,7 +134,7 @@ namespace Bit.Core.Models.Table
|
||||
|
||||
public long StorageBytesRemaining()
|
||||
{
|
||||
if(!MaxStorageGb.HasValue)
|
||||
if (!MaxStorageGb.HasValue)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
@ -145,7 +145,7 @@ namespace Bit.Core.Models.Table
|
||||
public long StorageBytesRemaining(short maxStorageGb)
|
||||
{
|
||||
var maxStorageBytes = maxStorageGb * 1073741824L;
|
||||
if(!Storage.HasValue)
|
||||
if (!Storage.HasValue)
|
||||
{
|
||||
return maxStorageBytes;
|
||||
}
|
||||
|
@ -43,7 +43,7 @@ namespace Bit.Core.Models
|
||||
|
||||
public static bool RequiresPremium(TwoFactorProviderType type)
|
||||
{
|
||||
switch(type)
|
||||
switch (type)
|
||||
{
|
||||
case TwoFactorProviderType.Duo:
|
||||
case TwoFactorProviderType.YubiKey:
|
||||
|
Reference in New Issue
Block a user