Merge pull request #2194 from matiu/enforce-passwords

Enforce Strong passwords
This commit is contained in:
Gustavo Maximiliano Cortez 2014-12-19 00:42:33 -03:00
commit 94d6916a75
5 changed files with 26 additions and 11 deletions

View File

@ -73,6 +73,8 @@ var defaultConfig = {
salt: 'jBbYTj8zTrOt6V',
},
minPasswordStrength: 4,
/*
GoogleDrive: {
home: 'copay',

View File

@ -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;

View File

@ -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;
@ -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;
}
});
}

View File

@ -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');
});
});

View File

@ -147,11 +147,24 @@
</form>
<form ng-show="createStep == 'pass'" name="passForm" ng-submit="createProfile(passForm)" novalidate>
<div class="box-notification" ng-show="passwordStrength">
<div class="box-icon" style="background-color:{{passwordStrength.color}}">
<i class="fi-x size-24" ng-if="passwordStrength.strength< minPasswordStrength"></i>
<i class="fi-check size-24" ng-if="passwordStrength.strength >= minPasswordStrength"></i>
</div>
<span class="size-14" >
Password Strength: {{passwordStrength.message}}
</span>
</div>
<div class="input">
<input id="password" type="password" ng-model="$parent.password" class="form-control" name="password" placeholder="{{'Choose a password'|translate}}" check-strength="passwordStrength" tooltip-html-unsafe="Password strength: <b>{{passwordStrength}}</b><br/><span class='size-12'>Tip: Use lower and uppercase, numbers and symbols</span>" tooltip-trigger="focus" required tooltip-placement="top">
<input id="password" type="password" ng-model="$parent.password" class="form-control" name="password" placeholder="{{'Choose a password'|translate}}" check-strength="passwordStrength" >
<i class="icon-locked"></i>
</div>
<div class="input">
<input type="password" ng-model="repeatpassword" class="input form-control" name="repeatpassword" placeholder="{{'Repeat password'|translate}}" match="password" required>
<i class="icon-locked"></i>
@ -167,7 +180,7 @@
</div>
</div>
<button translate type="submit" class="button primary radius expand m0" ng-disabled="passForm.$invalid">
<button translate type="submit" class="button primary radius expand m0" ng-disabled="passForm.$invalid || passwordStrength.strength < minPasswordStrength">
Create Profile
</button>