DocSpace-buildtools/web/ASC.Web.Core/Utility/PasswordSettings.cs

50 lines
1.4 KiB
C#
Raw Normal View History

2019-06-07 08:59:07 +00:00
namespace ASC.Web.Core.Utility
{
[Serializable]
2019-11-08 15:11:30 +00:00
public sealed class PasswordSettings : ISettings
2019-06-07 08:59:07 +00:00
{
public Guid ID
2019-06-07 08:59:07 +00:00
{
get { return new Guid("aa93a4d1-012d-4ccd-895a-e094e809c840"); }
}
public const int MaxLength = 30;
/// <summary>
/// Minimal length password has
/// </summary>
public int MinLength { get; set; }
/// <summary>
/// Password must contains upper case
/// </summary>
public bool UpperCase { get; set; }
/// <summary>
/// Password must contains digits
/// </summary>
public bool Digits { get; set; }
/// <summary>
/// Password must contains special symbols
/// </summary>
public bool SpecSymbols { get; set; }
public ISettings GetDefault(IConfiguration configuration)
2019-09-13 11:18:27 +00:00
{
2020-09-18 07:59:23 +00:00
var def = new PasswordSettings { MinLength = 8, UpperCase = false, Digits = false, SpecSymbols = false };
2019-09-13 11:18:27 +00:00
if (int.TryParse(configuration["web.password.min"], out var defaultMinLength))
2019-06-07 08:59:07 +00:00
{
def.MinLength = Math.Max(1, Math.Min(MaxLength, defaultMinLength));
2019-06-07 08:59:07 +00:00
}
return def;
}
public ISettings GetDefault(IServiceProvider serviceProvider)
{
return GetDefault(serviceProvider.GetService<IConfiguration>());
2019-06-07 08:59:07 +00:00
}
}
}