diff --git a/Oqtane.Client/Modules/Admin/Register/Index.razor b/Oqtane.Client/Modules/Admin/Register/Index.razor index 24ca61b5..7074e6c4 100644 --- a/Oqtane.Client/Modules/Admin/Register/Index.razor +++ b/Oqtane.Client/Modules/Admin/Register/Index.razor @@ -4,6 +4,7 @@ @inject IUserService UserService @inject IStringLocalizer Localizer @inject IStringLocalizer SharedLocalizer +@inject ISettingService SettingService @if (PageState.Site.AllowRegistration) { @@ -15,7 +16,7 @@ - +
@@ -24,6 +25,14 @@
+@*
+
+
+ +
+
*@
@@ -68,21 +77,55 @@ else } @code { - private string _username = string.Empty; - private ElementReference form; - private bool validated = false; - private string _password = string.Empty; - private string _passwordtype = "password"; - private string _togglepassword = string.Empty; - private string _confirm = string.Empty; - private string _email = string.Empty; - private string _displayname = string.Empty; + private string _username = string.Empty; + private ElementReference form; + private bool validated = false; + private string _password = string.Empty; + private string _passwordtype = "password"; + private string _togglepassword = string.Empty; + private string _confirm = string.Empty; + private string _email = string.Empty; + private string _displayname = string.Empty; - public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Anonymous; + //Password construction + private string _minimumlength; + private string _uniquecharacters; + private bool _requiredigit; + private bool _requireupper; + private bool _requirelower; + private bool _requirepunctuation; + private string _passwordconstruction; - protected override void OnParametersSet() + public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Anonymous; + + protected override async Task OnInitializedAsync() + { + var settings = await SettingService.GetSiteSettingsAsync(PageState.Site.SiteId); + var emailaddress = Localizer["Info.Registration.InvalidEmail"]; + string passwordValidationCriteriaTemplate = Localizer["Password.ValidationCriteria"]; + + _minimumlength = SettingService.GetSetting(settings, "IdentityOptions:Password:RequiredLength", "6"); + _uniquecharacters = SettingService.GetSetting(settings, "IdentityOptions:Password:RequiredUniqueChars", "1"); + _requiredigit = bool.Parse(SettingService.GetSetting(settings, "IdentityOptions:Password:RequireDigit", "true")); + _requireupper = bool.Parse(SettingService.GetSetting(settings, "IdentityOptions:Password:RequireUppercase", "true")); + _requirelower = bool.Parse(SettingService.GetSetting(settings, "IdentityOptions:Password:RequireLowercase", "true")); + _requirepunctuation = bool.Parse(SettingService.GetSetting(settings, "IdentityOptions:Password:RequireNonAlphanumeric", "true")); + + // Replace the placeholders with the actual values of the variables + string digitRequirement = _requiredigit ? Localizer["Password.DigitRequirement"] + ", " : ""; + string uppercaseRequirement = _requireupper ? Localizer["Password.UppercaseRequirement"] + ", " : ""; + string lowercaseRequirement = _requirelower ? Localizer["Password.LowercaseRequirement"] + ", " : ""; + string punctuationRequirement = _requirepunctuation ? Localizer["Password.PunctuationRequirement"] + ", " : ""; + + // Replace the placeholders with the actual values of the variables + _passwordconstruction = emailaddress + "
" + string.Format(passwordValidationCriteriaTemplate, + _minimumlength, _uniquecharacters, digitRequirement, uppercaseRequirement, lowercaseRequirement, punctuationRequirement); + } + + protected override void OnParametersSet() { _togglepassword = SharedLocalizer["ShowPassword"]; + } private async Task Register() diff --git a/Oqtane.Client/Resources/Modules/Admin/Register/Index.resx b/Oqtane.Client/Resources/Modules/Admin/Register/Index.resx index 4ce1b471..bd9c1724 100644 --- a/Oqtane.Client/Resources/Modules/Admin/Register/Index.resx +++ b/Oqtane.Client/Resources/Modules/Admin/Register/Index.resx @@ -177,4 +177,19 @@ Username: + + To ensure a strong and secure password, the password construction should meet the following criteria: it should have a minimum length of {0} characters, including at least {1} unique character(s), {2}{3}{4}{5} to meet the requirements. + + + at least one digit + + + at least one lowercase letter + + + at least one punctuation mark + + + at least one uppercase letter + \ No newline at end of file