fix min character assignments for pw gen

This commit is contained in:
Kyle Spearrin 2019-10-05 20:39:42 -04:00
parent a363712127
commit 0e966c0304

View file

@ -51,25 +51,44 @@ namespace Bit.Core.Services
{ {
options.MinUppercase = 1; options.MinUppercase = 1;
} }
else if(!options.Uppercase.GetValueOrDefault())
{
options.MinUppercase = 0;
}
if(options.Lowercase.GetValueOrDefault() && options.MinLowercase.GetValueOrDefault() <= 0) if(options.Lowercase.GetValueOrDefault() && options.MinLowercase.GetValueOrDefault() <= 0)
{ {
options.MinLowercase = 1; options.MinLowercase = 1;
} }
else if(!options.Lowercase.GetValueOrDefault())
{
options.MinLowercase = 0;
}
if(options.Number.GetValueOrDefault() && options.MinNumber.GetValueOrDefault() <= 0) if(options.Number.GetValueOrDefault() && options.MinNumber.GetValueOrDefault() <= 0)
{ {
options.MinNumber = 1; options.MinNumber = 1;
} }
else if(!options.Number.GetValueOrDefault())
{
options.MinNumber = 0;
}
if(options.Special.GetValueOrDefault() && options.MinSpecial.GetValueOrDefault() <= 0) if(options.Special.GetValueOrDefault() && options.MinSpecial.GetValueOrDefault() <= 0)
{ {
options.MinSpecial = 1; options.MinSpecial = 1;
} }
else if(!options.Special.GetValueOrDefault())
{
options.MinSpecial = 0;
}
if(options.Length.GetValueOrDefault() < 1) if(options.Length.GetValueOrDefault() < 1)
{ {
options.Length = 10; options.Length = 10;
} }
var minLength = options.MinSpecial.GetValueOrDefault() + options.MinLowercase.GetValueOrDefault() + var minLength = options.MinSpecial.GetValueOrDefault() + options.MinLowercase.GetValueOrDefault() +
options.MinNumber.GetValueOrDefault() + options.MinSpecial.GetValueOrDefault(); options.MinNumber.GetValueOrDefault() + options.MinUppercase.GetValueOrDefault();
if(options.Length < minLength) if(options.Length < minLength)
{ {
options.Length = minLength; options.Length = minLength;