From 058a19167388e54cd404af9a92ab11044058f255 Mon Sep 17 00:00:00 2001 From: Leigh Pointer Date: Fri, 24 Mar 2023 12:38:27 +0100 Subject: [PATCH 1/3] Modified Registration to display the Password requirments --- .../Modules/Admin/Register/Index.razor | 65 +++++++++++++++---- .../Modules/Admin/Register/Index.resx | 15 +++++ 2 files changed, 69 insertions(+), 11 deletions(-) diff --git a/Oqtane.Client/Modules/Admin/Register/Index.razor b/Oqtane.Client/Modules/Admin/Register/Index.razor index 24ca61b5..63a92807 100644 --- a/Oqtane.Client/Modules/Admin/Register/Index.razor +++ b/Oqtane.Client/Modules/Admin/Register/Index.razor @@ -1,9 +1,11 @@ @namespace Oqtane.Modules.Admin.Register @inherits ModuleBase +@using System.Resources; @inject NavigationManager NavigationManager @inject IUserService UserService @inject IStringLocalizer Localizer @inject IStringLocalizer SharedLocalizer +@inject ISettingService SettingService @if (PageState.Site.AllowRegistration) { @@ -24,6 +26,14 @@ +
+
+
+ +
+
@@ -68,21 +78,54 @@ 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); + _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")); + + string passwordValidationCriteriaTemplate = Localizer["Password.ValidationCriteria"]; + + // 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 = 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 From 9aa0374dc2869c268164eca54e8ba10e95c568f3 Mon Sep 17 00:00:00 2001 From: Leigh Pointer Date: Fri, 24 Mar 2023 12:41:27 +0100 Subject: [PATCH 2/3] Removed unused Using --- Oqtane.Client/Modules/Admin/Register/Index.razor | 1 - 1 file changed, 1 deletion(-) diff --git a/Oqtane.Client/Modules/Admin/Register/Index.razor b/Oqtane.Client/Modules/Admin/Register/Index.razor index 63a92807..12fe1340 100644 --- a/Oqtane.Client/Modules/Admin/Register/Index.razor +++ b/Oqtane.Client/Modules/Admin/Register/Index.razor @@ -1,6 +1,5 @@ @namespace Oqtane.Modules.Admin.Register @inherits ModuleBase -@using System.Resources; @inject NavigationManager NavigationManager @inject IUserService UserService @inject IStringLocalizer Localizer From 0f707a76078fed5d0da5f74f2aa31af4202e43e2 Mon Sep 17 00:00:00 2001 From: Leigh Pointer Date: Sat, 25 Mar 2023 11:47:15 +0100 Subject: [PATCH 3/3] Moved message to the notification. To be honest, the message about the password should be visible at all times. --- .../Modules/Admin/Register/Index.razor | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/Oqtane.Client/Modules/Admin/Register/Index.razor b/Oqtane.Client/Modules/Admin/Register/Index.razor index 12fe1340..7074e6c4 100644 --- a/Oqtane.Client/Modules/Admin/Register/Index.razor +++ b/Oqtane.Client/Modules/Admin/Register/Index.razor @@ -16,7 +16,7 @@ - +
@@ -25,14 +25,14 @@
-
+@*
-
+
*@
@@ -101,23 +101,24 @@ else 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")); - - string passwordValidationCriteriaTemplate = Localizer["Password.ValidationCriteria"]; - + // 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 = string.Format(passwordValidationCriteriaTemplate, + _passwordconstruction = emailaddress + "
" + string.Format(passwordValidationCriteriaTemplate, _minimumlength, _uniquecharacters, digitRequirement, uppercaseRequirement, lowercaseRequirement, punctuationRequirement); }