mirror of
https://github.com/bitwarden/server
synced 2026-01-17 16:03:49 +00:00
[PM-2944] Make Entities Nullable On Unowned Types (#4388)
* Enable `nullable` For Collection * Enable `nullable` For `CollectionCipher` * Enable `nullable` For `CollectionGroup` * Enable `nullable` For `CollectionUser` * Enable `nullable` For `Device` * Enable `nullable` For `Event` * Enable `nullable` For `Folder` * Enable `nullable` For `Installation` * Enable `nullable` For `IRevisable` * Enable `nullable` For `IStorable` * Enable `nullable` For `IStorableSubscriber` * Enable `nullable` For `ITableObject` * Enable `nullable` For `OrganizationApiKey` * Enable `nullable` For `OrganizationConnection` * Enable `nullable` For `OrganizationDomain` * Enable `nullable` For `OrganizationSponsorship` * Enable `nullable` For `Role` * Enable `nullable` For `TaxRate` * Enable `nullable` For `Transaction` * Enable `nullable` For `User`
This commit is contained in:
@@ -7,37 +7,39 @@ using Bit.Core.Tools.Entities;
|
||||
using Bit.Core.Utilities;
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
|
||||
#nullable enable
|
||||
|
||||
namespace Bit.Core.Entities;
|
||||
|
||||
public class User : ITableObject<Guid>, IStorableSubscriber, IRevisable, ITwoFactorProvidersUser, IReferenceable
|
||||
{
|
||||
private Dictionary<TwoFactorProviderType, TwoFactorProvider> _twoFactorProviders;
|
||||
private Dictionary<TwoFactorProviderType, TwoFactorProvider>? _twoFactorProviders;
|
||||
|
||||
public Guid Id { get; set; }
|
||||
[MaxLength(50)]
|
||||
public string Name { get; set; }
|
||||
public string? Name { get; set; }
|
||||
[Required]
|
||||
[MaxLength(256)]
|
||||
public string Email { get; set; }
|
||||
public string Email { get; set; } = null!;
|
||||
public bool EmailVerified { get; set; }
|
||||
[MaxLength(300)]
|
||||
public string MasterPassword { get; set; }
|
||||
public string? MasterPassword { get; set; }
|
||||
[MaxLength(50)]
|
||||
public string MasterPasswordHint { get; set; }
|
||||
public string? MasterPasswordHint { get; set; }
|
||||
[MaxLength(10)]
|
||||
public string Culture { get; set; } = "en-US";
|
||||
[Required]
|
||||
[MaxLength(50)]
|
||||
public string SecurityStamp { get; set; }
|
||||
public string TwoFactorProviders { get; set; }
|
||||
public string SecurityStamp { get; set; } = null!;
|
||||
public string? TwoFactorProviders { get; set; }
|
||||
[MaxLength(32)]
|
||||
public string TwoFactorRecoveryCode { get; set; }
|
||||
public string EquivalentDomains { get; set; }
|
||||
public string ExcludedGlobalEquivalentDomains { get; set; }
|
||||
public string? TwoFactorRecoveryCode { get; set; }
|
||||
public string? EquivalentDomains { get; set; }
|
||||
public string? ExcludedGlobalEquivalentDomains { get; set; }
|
||||
public DateTime AccountRevisionDate { get; set; } = DateTime.UtcNow;
|
||||
public string Key { get; set; }
|
||||
public string PublicKey { get; set; }
|
||||
public string PrivateKey { get; set; }
|
||||
public string? Key { get; set; }
|
||||
public string? PublicKey { get; set; }
|
||||
public string? PrivateKey { get; set; }
|
||||
public bool Premium { get; set; }
|
||||
public DateTime? PremiumExpirationDate { get; set; }
|
||||
public DateTime? RenewalReminderDate { get; set; }
|
||||
@@ -45,15 +47,15 @@ public class User : ITableObject<Guid>, IStorableSubscriber, IRevisable, ITwoFac
|
||||
public short? MaxStorageGb { get; set; }
|
||||
public GatewayType? Gateway { get; set; }
|
||||
[MaxLength(50)]
|
||||
public string GatewayCustomerId { get; set; }
|
||||
public string? GatewayCustomerId { get; set; }
|
||||
[MaxLength(50)]
|
||||
public string GatewaySubscriptionId { get; set; }
|
||||
public string ReferenceData { get; set; }
|
||||
public string? GatewaySubscriptionId { get; set; }
|
||||
public string? ReferenceData { get; set; }
|
||||
[MaxLength(100)]
|
||||
public string LicenseKey { get; set; }
|
||||
public string? LicenseKey { get; set; }
|
||||
[Required]
|
||||
[MaxLength(30)]
|
||||
public string ApiKey { get; set; }
|
||||
public string ApiKey { get; set; } = null!;
|
||||
public KdfType Kdf { get; set; } = KdfType.PBKDF2_SHA256;
|
||||
public int KdfIterations { get; set; } = AuthConstants.PBKDF2_ITERATIONS.Default;
|
||||
public int? KdfMemory { get; set; }
|
||||
@@ -65,7 +67,7 @@ public class User : ITableObject<Guid>, IStorableSubscriber, IRevisable, ITwoFac
|
||||
public int FailedLoginCount { get; set; }
|
||||
public DateTime? LastFailedLoginDate { get; set; }
|
||||
[MaxLength(7)]
|
||||
public string AvatarColor { get; set; }
|
||||
public string? AvatarColor { get; set; }
|
||||
public DateTime? LastPasswordChangeDate { get; set; }
|
||||
public DateTime? LastKdfChangeDate { get; set; }
|
||||
public DateTime? LastKeyRotationDate { get; set; }
|
||||
@@ -76,12 +78,12 @@ public class User : ITableObject<Guid>, IStorableSubscriber, IRevisable, ITwoFac
|
||||
Id = CoreHelpers.GenerateComb();
|
||||
}
|
||||
|
||||
public string BillingEmailAddress()
|
||||
public string? BillingEmailAddress()
|
||||
{
|
||||
return Email?.ToLowerInvariant()?.Trim();
|
||||
}
|
||||
|
||||
public string BillingName()
|
||||
public string? BillingName()
|
||||
{
|
||||
return Name;
|
||||
}
|
||||
@@ -125,7 +127,7 @@ public class User : ITableObject<Guid>, IStorableSubscriber, IRevisable, ITwoFac
|
||||
|
||||
public bool IsExpired() => PremiumExpirationDate.HasValue && PremiumExpirationDate.Value <= DateTime.UtcNow;
|
||||
|
||||
public Dictionary<TwoFactorProviderType, TwoFactorProvider> GetTwoFactorProviders()
|
||||
public Dictionary<TwoFactorProviderType, TwoFactorProvider>? GetTwoFactorProviders()
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(TwoFactorProviders))
|
||||
{
|
||||
@@ -178,7 +180,7 @@ public class User : ITableObject<Guid>, IStorableSubscriber, IRevisable, ITwoFac
|
||||
SetTwoFactorProviders(new Dictionary<TwoFactorProviderType, TwoFactorProvider>());
|
||||
}
|
||||
|
||||
public TwoFactorProvider GetTwoFactorProvider(TwoFactorProviderType provider)
|
||||
public TwoFactorProvider? GetTwoFactorProvider(TwoFactorProviderType provider)
|
||||
{
|
||||
var providers = GetTwoFactorProviders();
|
||||
if (providers == null || !providers.ContainsKey(provider))
|
||||
|
||||
Reference in New Issue
Block a user