1
0
mirror of https://github.com/bitwarden/server synced 2026-01-28 23:36:12 +00:00

fix(register): [PM-27084] Account Register Uses New Data Types - Added more comments and fixed up some long lines.

This commit is contained in:
Patrick Pimentel
2025-12-10 17:47:12 -05:00
parent 1535fa35d3
commit 9000474b5a
2 changed files with 18 additions and 8 deletions

View File

@@ -25,23 +25,25 @@ public class RegisterFinishRequestModel : IValidatableObject
public MasterPasswordAuthenticationData? MasterPasswordAuthenticationData { get; set; }
public MasterPasswordUnlockData? MasterPasswordUnlockData { get; set; }
// PM-28143 - Remove line below (made optional during migration to MasterPasswordUnlockData
// PM-28143 - Remove line below (made optional during migration to MasterPasswordUnlockData)
[StringLength(1000)]
public string? MasterPasswordHash { get; set; }
[StringLength(50)]
public string? MasterPasswordHint { get; set; }
// PM-28143 - Remove line below (made optional during migration to MasterPasswordUnlockData
// PM-28143 - Remove line below (made optional during migration to MasterPasswordUnlockData)
public string? UserSymmetricKey { get; set; }
public required KeysRequestModel UserAsymmetricKeys { get; set; }
// PM-28143 - Remove line below (made optional during migration to MasterPasswordUnlockData
// PM-28143 - Remove line below (made optional during migration to MasterPasswordUnlockData)
public KdfType? Kdf { get; set; }
// PM-28143 - Remove line below (made optional during migration to MasterPasswordUnlockData
// PM-28143 - Remove line below (made optional during migration to MasterPasswordUnlockData)
public int? KdfIterations { get; set; }
// PM-28143 - Remove line below
public int? KdfMemory { get; set; }
// PM-28143 - Remove line below
public int? KdfParallelism { get; set; }
public Guid? OrganizationUserId { get; set; }
@@ -105,10 +107,16 @@ public class RegisterFinishRequestModel : IValidatableObject
public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
{
var kdf = MasterPasswordUnlockData?.Kdf.KdfType ?? Kdf ?? throw new Exception($"{nameof(Kdf)} not found on RequestModel");
var kdfIterations = MasterPasswordUnlockData?.Kdf.Iterations ?? KdfIterations ?? throw new Exception($"{nameof(KdfIterations)} not found on RequestModel");
var kdfMemory = MasterPasswordUnlockData?.Kdf.Memory ?? KdfMemory;
var kdfParallelism = MasterPasswordUnlockData?.Kdf.Parallelism ?? KdfParallelism;
var kdf = MasterPasswordUnlockData?.Kdf.KdfType
?? Kdf
?? throw new Exception($"{nameof(Kdf)} not found on RequestModel");
var kdfIterations = MasterPasswordUnlockData?.Kdf.Iterations
?? KdfIterations
?? throw new Exception($"{nameof(KdfIterations)} not found on RequestModel");
var kdfMemory = MasterPasswordUnlockData?.Kdf.Memory
?? KdfMemory;
var kdfParallelism = MasterPasswordUnlockData?.Kdf.Parallelism
?? KdfParallelism;
// PM-28143 - Remove line below in favor of using the unlock data.
return KdfSettingsValidator.Validate(kdf, kdfIterations, kdfMemory, kdfParallelism);

View File

@@ -6,6 +6,7 @@ namespace Bit.Core.Utilities;
public static class KdfSettingsValidator
{
// PM-28143 - Remove below when fixing ticket
public static IEnumerable<ValidationResult> Validate(KdfType kdfType, int kdfIterations, int? kdfMemory, int? kdfParallelism)
{
switch (kdfType)
@@ -36,6 +37,7 @@ public static class KdfSettingsValidator
}
}
// PM-28143 - Will be used in the referenced ticket.
public static IEnumerable<ValidationResult> Validate(MasterPasswordUnlockData masterPasswordUnlockData)
{
switch (masterPasswordUnlockData.Kdf.KdfType)