- Renamed validatePassword method, usePwstrength and useZxcvbn,

- Moved passwordOptions from settings.json to ActiveEntry configuration object
- Used zxcvbn rule set if showPasswordStrengthIndicator is true, used regular expression rule set if showPasswordStrengthIndicator is false
This commit is contained in:
Aysel Afsar committed 2016-02-04 17:53:01 -05:00
1 parent 4e986c8395
commit e659f0f4b3
17 files changed
+165 -102

No files matched your search

+9 -2
View File
@@ -22,6 +22,10 @@ if (Meteor.isClient) {
},
themeColors: {
primary: ""
},
passwordOptions: {
requireStrongPasswords: false,
showPasswordStrengthIndicator: false
}
});
}
@@ -33,6 +37,9 @@ if (Meteor.isClient) {
// Success messages
ActiveEntry.successMessages = new ReactiveDict('successMessages');
// Change password warning message according to whether zxcvbn is turned on
Session.set('passwordWarning', 'Password must have at least 8 characters. It must contain at least 1 uppercase, 1 lowercase, 1 number and 1 special character.');
}
ActiveEntry.configure = function (configObject) {
@@ -45,8 +52,8 @@ ActiveEntry.verifyPassword = function (password) {
if (password.length === 0) {
ActiveEntry.errorMessages.set('password', 'Password is required');
ActiveEntry.successMessages.set('password', null);
} else if (!validatePassword(password)) {
ActiveEntry.errorMessages.set('password', 'Password must have at least 8 characters. It must contain at least 1 uppercase, 1 lowercase, 1 number and 1 special character.');
} else if (!checkPasswordStrength(password)) {
ActiveEntry.errorMessages.set('password', Session.get('passwordWarning'));
ActiveEntry.successMessages.set('password', null);
} else {
//ActiveEntry.errorMessages.set('password', 'Password present');
@@ -0,0 +1,46 @@
passwordValidationSettings = {};
var ActiveEntryConfiguration;
Meteor.startup(function() {
ActiveEntryConfiguration = Session.get('Photonic.ActiveEntry');
var showPasswordStrengthIndicator = (ActiveEntryConfiguration && ActiveEntryConfiguration.passwordOptions && ActiveEntryConfiguration.passwordOptions.showPasswordStrengthIndicator || false);
passwordValidationSettings.requireStrongPasswords = (ActiveEntryConfiguration && ActiveEntryConfiguration.passwordOptions && ActiveEntryConfiguration.passwordOptions.requireStrongPasswords || false);
passwordValidationSettings.showPasswordStrengthIndicator = showPasswordStrengthIndicator;
passwordValidationSettings.pwstrengthOptions = {
common: {
minChar: 8,
zxcvbn: showPasswordStrengthIndicator
},
ui: {
showVerdictsInsideProgressBar: true,
showStatus: true
},
rules: {
activated: {
wordNotEmail: true,
wordTwoCharacterClasses: true,
wordRepetitions: true
}
}
};
});
// Check Password Strength: at least 8 characters in length and contain at least 1 uppercase, 1 lowercase and 1 number and 1 special character
checkPasswordStrength = function(password) {
var iszxcvbnActive = (ActiveEntryConfiguration && ActiveEntryConfiguration.passwordOptions && ActiveEntryConfiguration.passwordOptions.showPasswordStrengthIndicator || false);
if (iszxcvbnActive) {
// Check zxcvbn rule
var zxcvbnResult = zxcvbn(password);
if (zxcvbnResult.score > 2) {
return true;
}
} else{
// Apply validation rule
var result = password.search(/^(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[!@#$%^&*])[0-9a-zA-Z!@#$%^&*]{8,}$/i);
if (result > -1) {
return true;
}
}
return false;
};
@@ -1,24 +0,0 @@
passwordValidationSettings = {};
Meteor.startup(function(){
passwordValidationSettings.usePwstrength = Meteor.settings.public.usePwstrength;
passwordValidationSettings.pwstrengthOptions = {
common: {
minChar: 8,
zxcvbn: (Meteor.settings.public.useZxcvbn || false)
},
ui: {
showVerdictsInsideProgressBar: true,
showStatus: true
}
}
});
// Validate Password: at least 8 characters in length and contain at least 1 uppercase, 1 lowercase and 1 number and 1 special character
validatePassword = function(password) {
var result = password.search(/^(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[!@#$%^&*])[0-9a-zA-Z!@#$%^&*]{8,}$/i);
if (result > -1) {
return true;
}
return false;
};