From 2021ea979c992595c0c652480187dbfd9dbd9a83 Mon Sep 17 00:00:00 2001 From: Matias Alejo Garcia Date: Wed, 17 Dec 2014 10:37:11 -0300 Subject: [PATCH 1/4] WIP: password directive --- js/directives.js | 5 +---- views/createProfile.html | 13 ++++++++++++- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/js/directives.js b/js/directives.js index a83fd7d1c..afbdf8cf3 100644 --- a/js/directives.js +++ b/js/directives.js @@ -250,10 +250,7 @@ angular.module('copayApp.directives') scope.$watch(attrs.ngModel, function(newValue, oldValue) { if (newValue && newValue !== '') { var info = evaluateMeter(newValue); - element.css({ - 'border-color': info.color - }); - scope[attrs.checkStrength] = info.message; + scope[attrs.checkStrength] = info; } }); } diff --git a/views/createProfile.html b/views/createProfile.html index 7503a48e9..4a1af88ce 100644 --- a/views/createProfile.html +++ b/views/createProfile.html @@ -148,10 +148,21 @@
- +
+
+
+ + +
+ + Password Strength: {{passwordStrength.message}} + +
+ +
From 70441e0aada1d915d219dc8760bb749eb6d53a3c Mon Sep 17 00:00:00 2001 From: Matias Alejo Garcia Date: Wed, 17 Dec 2014 12:08:10 -0300 Subject: [PATCH 2/4] UX ready --- views/createProfile.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/views/createProfile.html b/views/createProfile.html index 4a1af88ce..7409924f8 100644 --- a/views/createProfile.html +++ b/views/createProfile.html @@ -154,8 +154,8 @@
- - + +
Password Strength: {{passwordStrength.message}} From eb2270a2d1c81a94782f521261ff04a6352688d0 Mon Sep 17 00:00:00 2001 From: Matias Alejo Garcia Date: Thu, 18 Dec 2014 20:05:13 -0300 Subject: [PATCH 3/4] add config --- config.js | 2 ++ js/controllers/createProfile.js | 2 ++ js/directives.js | 2 +- views/createProfile.html | 24 +++++++++++++----------- 4 files changed, 18 insertions(+), 12 deletions(-) diff --git a/config.js b/config.js index 6ccd05934..b99dc7d25 100644 --- a/config.js +++ b/config.js @@ -73,6 +73,8 @@ var defaultConfig = { salt: 'jBbYTj8zTrOt6V', }, + minPasswordStrength: 4, + /* GoogleDrive: { home: 'copay', diff --git a/js/controllers/createProfile.js b/js/controllers/createProfile.js index 3f15df04b..b3e76404a 100644 --- a/js/controllers/createProfile.js +++ b/js/controllers/createProfile.js @@ -13,6 +13,8 @@ angular.module('copayApp.controllers').controller('CreateProfileController', fun $scope.createStep = 'storage'; $scope.useLocalstorage = false; + $scope.minPasswordStrength = _.isUndefined(config.minPasswordStrength) ? + 4 : config.minPasswordStrength; pinService.makePinInput($scope, 'newpin', function(newValue) { _firstpin = newValue; diff --git a/js/directives.js b/js/directives.js index afbdf8cf3..6649261f8 100644 --- a/js/directives.js +++ b/js/directives.js @@ -208,7 +208,7 @@ angular.module('copayApp.directives') var MIN_LENGTH = 8; var MESSAGES = ['Very Weak', 'Very Weak', 'Weak', 'Medium', 'Strong', 'Very Strong']; - var COLOR = ['#dd514c', '#dd514c', '#faa732', '#faa732', '#5eb95e', '#5eb95e']; + var COLOR = ['#dd514c', '#dd514c', '#faa732', '#faa732', '#16A085', '#16A085']; function evaluateMeter(password) { var passwordStrength = 0; diff --git a/views/createProfile.html b/views/createProfile.html index 7409924f8..d0a0c86ad 100644 --- a/views/createProfile.html +++ b/views/createProfile.html @@ -147,21 +147,23 @@
+ +
+
+ + +
+ + Password Strength: {{passwordStrength.message}} + +
+ +
-
-
- - -
- - Password Strength: {{passwordStrength.message}} - -
-
@@ -178,7 +180,7 @@
- From 189a86bc074edfd1292b0c82faad4a3d1679cf7d Mon Sep 17 00:00:00 2001 From: Matias Alejo Garcia Date: Fri, 19 Dec 2014 00:34:13 -0300 Subject: [PATCH 4/4] karma... wake up! --- test/unit/directives/directivesSpec.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/test/unit/directives/directivesSpec.js b/test/unit/directives/directivesSpec.js index d8d60c304..507e3c159 100644 --- a/test/unit/directives/directivesSpec.js +++ b/test/unit/directives/directivesSpec.js @@ -191,25 +191,26 @@ describe("Unit: Testing Directives", function() { it('should check very weak password', function() { $scope.password = 'asd'; $scope.$digest(); - expect($scope.passwordStrength).to.equal('Very Weak, that\'s short'); + expect($scope.passwordStrength.strength).to.equal(1); }); + it('should check weak password', function() { $scope.password = 'asdasdASDASD'; $scope.$digest(); - expect($scope.passwordStrength).to.equal('Weak, add numerals'); + expect($scope.passwordStrength.message).to.equal('Weak, add numerals'); }); it('should check medium password', function() { $scope.password = 'asdasdA1'; $scope.$digest(); - expect($scope.passwordStrength).to.equal('Medium, add punctuation'); + expect($scope.passwordStrength.message).to.equal('Medium, add punctuation'); }); it('should check strong password', function() { $scope.password = 'asdasdASDASD1{'; $scope.$digest(); - expect($scope.passwordStrength).to.equal('Strong, add punctuation'); + expect($scope.passwordStrength.message).to.equal('Strong, add punctuation'); }); });