From 0e966c0304ed9408596c8cc6b05f50dcba22a44c Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Sat, 5 Oct 2019 20:39:42 -0400 Subject: [PATCH] fix min character assignments for pw gen --- .../Services/PasswordGenerationService.cs | 21 ++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/src/Core/Services/PasswordGenerationService.cs b/src/Core/Services/PasswordGenerationService.cs index 7321be26e..4519230e4 100644 --- a/src/Core/Services/PasswordGenerationService.cs +++ b/src/Core/Services/PasswordGenerationService.cs @@ -51,25 +51,44 @@ namespace Bit.Core.Services { options.MinUppercase = 1; } + else if(!options.Uppercase.GetValueOrDefault()) + { + options.MinUppercase = 0; + } + if(options.Lowercase.GetValueOrDefault() && options.MinLowercase.GetValueOrDefault() <= 0) { options.MinLowercase = 1; } + else if(!options.Lowercase.GetValueOrDefault()) + { + options.MinLowercase = 0; + } + if(options.Number.GetValueOrDefault() && options.MinNumber.GetValueOrDefault() <= 0) { options.MinNumber = 1; } + else if(!options.Number.GetValueOrDefault()) + { + options.MinNumber = 0; + } + if(options.Special.GetValueOrDefault() && options.MinSpecial.GetValueOrDefault() <= 0) { options.MinSpecial = 1; } + else if(!options.Special.GetValueOrDefault()) + { + options.MinSpecial = 0; + } if(options.Length.GetValueOrDefault() < 1) { options.Length = 10; } var minLength = options.MinSpecial.GetValueOrDefault() + options.MinLowercase.GetValueOrDefault() + - options.MinNumber.GetValueOrDefault() + options.MinSpecial.GetValueOrDefault(); + options.MinNumber.GetValueOrDefault() + options.MinUppercase.GetValueOrDefault(); if(options.Length < minLength) { options.Length = minLength;