From 3acf4b5a4ea7e9a5f75828f828f00aad1bdb5cf4 Mon Sep 17 00:00:00 2001 From: Matt Walker Date: Wed, 9 Nov 2016 17:00:36 -0500 Subject: [PATCH 1/3] Password complexity validation --- .../userRegistrationFormController.js | 3 +++ .../userRegistrationFormController.test.js | 10 ++++++++++ .../userRegistrationFormTemplate.html | 7 ++++--- 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/DOL.WHD.Section14c.Web/src/modules/components/userRegistrationForm/userRegistrationFormController.js b/DOL.WHD.Section14c.Web/src/modules/components/userRegistrationForm/userRegistrationFormController.js index beb4b4bd..c4a6a052 100644 --- a/DOL.WHD.Section14c.Web/src/modules/components/userRegistrationForm/userRegistrationFormController.js +++ b/DOL.WHD.Section14c.Web/src/modules/components/userRegistrationForm/userRegistrationFormController.js @@ -121,6 +121,9 @@ module.exports = function(ngModule) { if($scope.registerErrors.indexOf("Password does not meet complexity requirements.") > -1){ vm.passwordComplexity = true; } + if(some($scope.registerErrors, function(error) { return error.indexOf("Passwords must") > -1;})) { + vm.passwordComplexity = true; + } } else { vm.generalRegistrationError = true; } diff --git a/DOL.WHD.Section14c.Web/src/modules/components/userRegistrationForm/userRegistrationFormController.test.js b/DOL.WHD.Section14c.Web/src/modules/components/userRegistrationForm/userRegistrationFormController.test.js index 4e07c2ec..1b2295ba 100644 --- a/DOL.WHD.Section14c.Web/src/modules/components/userRegistrationForm/userRegistrationFormController.test.js +++ b/DOL.WHD.Section14c.Web/src/modules/components/userRegistrationForm/userRegistrationFormController.test.js @@ -180,6 +180,16 @@ describe('userRegistrationFormController', function() { expect(controller.passwordComplexity).toBe(true); }); + it('submitting registration has an error, Password does not meet complexity requirements. message is displayed', function() { + var controller = userRegistrationFormController(); + scope.onSubmitClick(); + scope.resetRegCaptcha = function() {}; + userRegister.reject({data: {"modelState":{"error":[ "Passwords must"] }}}); + scope.$apply(); + + expect(controller.passwordComplexity).toBe(true); + }); + it('submitting registration has an error, log error details', function() { var controller = userRegistrationFormController(); scope.onSubmitClick(); diff --git a/DOL.WHD.Section14c.Web/src/modules/components/userRegistrationForm/userRegistrationFormTemplate.html b/DOL.WHD.Section14c.Web/src/modules/components/userRegistrationForm/userRegistrationFormTemplate.html index 46d367d0..6c9ee5fc 100644 --- a/DOL.WHD.Section14c.Web/src/modules/components/userRegistrationForm/userRegistrationFormTemplate.html +++ b/DOL.WHD.Section14c.Web/src/modules/components/userRegistrationForm/userRegistrationFormTemplate.html @@ -58,7 +58,7 @@

Create an Account

-
+

Passwords must

@@ -68,11 +68,12 @@

Passwords must

  • Contain at least 1 lowercase leter.
  • Contain at least 1 special character.
  • Contain at least 1 number.
  • +
  • Meets "Good" password strength
  • -
    +
    @@ -95,7 +96,7 @@

    Passwords must

    -
    +
    From a496570c1c087e39c2b7bfb8f5ceac8d13bbf5c3 Mon Sep 17 00:00:00 2001 From: Matt Walker Date: Wed, 9 Nov 2016 17:02:54 -0500 Subject: [PATCH 2/3] punctuation --- .../userRegistrationForm/userRegistrationFormTemplate.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DOL.WHD.Section14c.Web/src/modules/components/userRegistrationForm/userRegistrationFormTemplate.html b/DOL.WHD.Section14c.Web/src/modules/components/userRegistrationForm/userRegistrationFormTemplate.html index 6c9ee5fc..992c45da 100644 --- a/DOL.WHD.Section14c.Web/src/modules/components/userRegistrationForm/userRegistrationFormTemplate.html +++ b/DOL.WHD.Section14c.Web/src/modules/components/userRegistrationForm/userRegistrationFormTemplate.html @@ -68,7 +68,7 @@

    Passwords must

  • Contain at least 1 lowercase leter.
  • Contain at least 1 special character.
  • Contain at least 1 number.
  • -
  • Meets "Good" password strength
  • +
  • Meets "Good" password strength.
  • From d79462aebae015c8dbce43c6ab438701d2eeb1b4 Mon Sep 17 00:00:00 2001 From: Matt Walker Date: Wed, 9 Nov 2016 17:18:14 -0500 Subject: [PATCH 3/3] reduced complexity --- .../userRegistrationFormController.js | 41 +++++-------------- 1 file changed, 10 insertions(+), 31 deletions(-) diff --git a/DOL.WHD.Section14c.Web/src/modules/components/userRegistrationForm/userRegistrationFormController.js b/DOL.WHD.Section14c.Web/src/modules/components/userRegistrationForm/userRegistrationFormController.js index c4a6a052..2482165c 100644 --- a/DOL.WHD.Section14c.Web/src/modules/components/userRegistrationForm/userRegistrationFormController.js +++ b/DOL.WHD.Section14c.Web/src/modules/components/userRegistrationForm/userRegistrationFormController.js @@ -78,7 +78,7 @@ module.exports = function(ngModule) { vm.emailVerificationError = true; console.log(error.statusText + (error.data && error.data.error ? ': ' + error.data.error + ' - ' + error.data.error_description : '')); }); - } + } $scope.onSubmitClick = function() { vm.resetErrors(); @@ -94,36 +94,15 @@ module.exports = function(ngModule) { }, function (error) { if(error && error.data){ $scope.registerErrors = apiService.parseErrors(error.data); - if($scope.registerErrors.indexOf("EIN is already registered") > -1){ - vm.einError = true; - } - if($scope.registerErrors.indexOf("Unable to validate reCaptcha Response") > -1){ - vm.reCaptchaError = true; - } - if(some($scope.registerErrors, function(error) { return error.indexOf("is already taken") > -1;})) { - vm.emailAddressError = true; - } - if($scope.registerErrors.indexOf("The Email field is required.") > -1){ - vm.emailAddressRequired = true; - } - if($scope.registerErrors.indexOf("The Password field is required.") > -1){ - vm.passwordRequired = true; - } - if($scope.registerErrors.indexOf("The EIN field is required.") > -1){ - vm.einRequired = true; - } - if(some($scope.registerErrors, function(error) { return error.indexOf("The field EIN must match") > -1;})) { - vm.invalidEin = true; - } - if($scope.registerErrors.indexOf("The password and confirmation password do not match.") > -1){ - vm.passwordsDontMatch = true; - } - if($scope.registerErrors.indexOf("Password does not meet complexity requirements.") > -1){ - vm.passwordComplexity = true; - } - if(some($scope.registerErrors, function(error) { return error.indexOf("Passwords must") > -1;})) { - vm.passwordComplexity = true; - } + vm.einError = $scope.registerErrors.indexOf("EIN is already registered") > -1; + vm.reCaptchaError = $scope.registerErrors.indexOf("Unable to validate reCaptcha Response") > -1; + vm.emailAddressError = some($scope.registerErrors, function(error) { return error.indexOf("is already taken") > -1;}); + vm.emailAddressRequired = $scope.registerErrors.indexOf("The Email field is required.") > -1; + vm.passwordRequired = $scope.registerErrors.indexOf("The Password field is required.") > -1; + vm.einRequired = $scope.registerErrors.indexOf("The EIN field is required.") > -1; + vm.invalidEin = some($scope.registerErrors, function(error) { return error.indexOf("The field EIN must match") > -1;}); + vm.passwordsDontMatch = $scope.registerErrors.indexOf("The password and confirmation password do not match.") > -1; + vm.passwordComplexity = $scope.registerErrors.indexOf("Password does not meet complexity requirements.") > -1 || some($scope.registerErrors, function(error) { return error.indexOf("Passwords must") > -1;}); } else { vm.generalRegistrationError = true; }