From 37937e2c8e07af5a1613e3441b29b3fad289d6dd Mon Sep 17 00:00:00 2001 From: Shannon Date: Thu, 6 Mar 2014 12:11:14 +1100 Subject: [PATCH] Fixes the user password validation to ensure it obeys what the membership provider's are configured for. --- .../src/installer/steps/user.controller.js | 13 ++++++++++++- .../src/installer/steps/user.html | 11 +++++++++-- .../Install/InstallSteps/NewInstallStep.cs | 17 ++++++++++++++++- .../Install/Models/InstallSetupStep.cs | 6 ++++++ 4 files changed, 43 insertions(+), 4 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/src/installer/steps/user.controller.js b/src/Umbraco.Web.UI.Client/src/installer/steps/user.controller.js index 133552a9f4..6c689a3166 100644 --- a/src/Umbraco.Web.UI.Client/src/installer/steps/user.controller.js +++ b/src/Umbraco.Web.UI.Client/src/installer/steps/user.controller.js @@ -1,4 +1,15 @@ -angular.module("umbraco.install").controller("Umbraco.Install.UserController", function($scope, installerService){ +angular.module("umbraco.install").controller("Umbraco.Install.UserController", function($scope, installerService) { + + $scope.passwordPattern = /.*/; + if ($scope.installer.current.model.minNonAlphaNumericLength > 0) { + var exp = ""; + for (var i = 0; i < $scope.installer.current.model.minNonAlphaNumericLength; i++) { + exp += ".*[\\W].*"; + } + //replace duplicates + exp = exp.replace(".*.*", ".*"); + $scope.passwordPattern = new RegExp(exp); + } $scope.validateAndInstall = function(){ installerService.install(); diff --git a/src/Umbraco.Web.UI.Client/src/installer/steps/user.html b/src/Umbraco.Web.UI.Client/src/installer/steps/user.html index e7ddcb3a70..0b8b44124a 100644 --- a/src/Umbraco.Web.UI.Client/src/installer/steps/user.html +++ b/src/Umbraco.Web.UI.Client/src/installer/steps/user.html @@ -27,8 +27,15 @@
- - Atleast 8 characters long + + At least {{installer.current.model.minCharLength}} characters long + + At least {{installer.current.model.minNonAlphaNumericLength}} symbol{{installer.current.model.minNonAlphaNumericLength > 1 ? 's' : ''}} +
diff --git a/src/Umbraco.Web/Install/InstallSteps/NewInstallStep.cs b/src/Umbraco.Web/Install/InstallSteps/NewInstallStep.cs index 468cc081b5..d2d764d5eb 100644 --- a/src/Umbraco.Web/Install/InstallSteps/NewInstallStep.cs +++ b/src/Umbraco.Web/Install/InstallSteps/NewInstallStep.cs @@ -72,10 +72,25 @@ namespace Umbraco.Web.Install.InstallSteps admin.Username = user.Email.Trim(); _applicationContext.Services.UserService.Save(admin); - + return null; } + /// + /// Return a custom view model for this step + /// + public override object ViewModel + { + get + { + return new + { + minCharLength = Membership.Providers[Constants.Conventions.User.UmbracoUsersProviderName].MinRequiredPasswordLength, + minNonAlphaNumericLength = Membership.Providers[Constants.Conventions.User.UmbracoUsersProviderName].MinRequiredNonAlphanumericCharacters + }; + } + } + public override string View { get { return RequiresExecution(null) diff --git a/src/Umbraco.Web/Install/Models/InstallSetupStep.cs b/src/Umbraco.Web/Install/Models/InstallSetupStep.cs index 6814ff413f..3cfa2659e2 100644 --- a/src/Umbraco.Web/Install/Models/InstallSetupStep.cs +++ b/src/Umbraco.Web/Install/Models/InstallSetupStep.cs @@ -57,6 +57,12 @@ namespace Umbraco.Web.Install.Models [DataMember(Name = "view")] public virtual string View { get; private set; } + /// + /// The view model used to render the view, by default is null but can be populated + /// + [DataMember(Name = "model")] + public virtual object ViewModel { get; private set; } + [DataMember(Name = "description")] public string Description { get; private set; }