Updates to Core.Configuration Models to use DefaultValue attribute to allow auto generated JSONSchema to give a default value in schema

This commit is contained in:
Warren Buckley
2021-07-05 14:27:49 +01:00
parent cd36d050c5
commit 6b73ea767f
28 changed files with 372 additions and 106 deletions

View File

@@ -1,6 +1,8 @@
// Copyright (c) Umbraco.
// See LICENSE for more details.
using System.ComponentModel;
namespace Umbraco.Cms.Core.Configuration.Models
{
/// <summary>
@@ -9,25 +11,39 @@ namespace Umbraco.Cms.Core.Configuration.Models
[UmbracoOptions(Constants.Configuration.ConfigMemberPassword)]
public class MemberPasswordConfigurationSettings : IPasswordConfiguration
{
/// <inheritdoc/>
public int RequiredLength { get; set; } = 10;
internal const int StaticRequiredLength = 10;
internal const bool StaticRequireNonLetterOrDigit = false;
internal const bool StaticRequireDigit = false;
internal const bool StaticRequireLowercase = false;
internal const bool StaticRequireUppercase = false;
internal const int StaticMaxFailedAccessAttemptsBeforeLockout = 5;
/// <inheritdoc/>
public bool RequireNonLetterOrDigit { get; set; } = false;
[DefaultValue(StaticRequiredLength)]
public int RequiredLength { get; set; } = StaticRequiredLength;
/// <inheritdoc/>
public bool RequireDigit { get; set; } = false;
[DefaultValue(StaticRequireNonLetterOrDigit)]
public bool RequireNonLetterOrDigit { get; set; } = StaticRequireNonLetterOrDigit;
/// <inheritdoc/>
public bool RequireLowercase { get; set; } = false;
[DefaultValue(StaticRequireDigit)]
public bool RequireDigit { get; set; } = StaticRequireDigit;
/// <inheritdoc/>
public bool RequireUppercase { get; set; } = false;
[DefaultValue(StaticRequireLowercase)]
public bool RequireLowercase { get; set; } = StaticRequireLowercase;
/// <inheritdoc/>
[DefaultValue(StaticRequireUppercase)]
public bool RequireUppercase { get; set; } = StaticRequireUppercase;
/// <inheritdoc/>
[DefaultValue(Constants.Security.AspNetCoreV3PasswordHashAlgorithmName)]
public string HashAlgorithmType { get; set; } = Constants.Security.AspNetCoreV3PasswordHashAlgorithmName;
/// <inheritdoc/>
public int MaxFailedAccessAttemptsBeforeLockout { get; set; } = 5;
[DefaultValue(StaticMaxFailedAccessAttemptsBeforeLockout)]
public int MaxFailedAccessAttemptsBeforeLockout { get; set; } = StaticMaxFailedAccessAttemptsBeforeLockout;
}
}