LT-97: - Remove zxcvbn package because of version conflict,

- Add passwordOptions in ActiveEntry.configure
- Toggle showPasswordStrengthIndicator to show password strength meter ui, toggle requireRegexValidation to set password regex for validation or requireStrongPasswords to create strong passwords by using zxcvbn.
- Sign in/ sing up when enter key is pressed
This commit is contained in:
Aysel Afsar committed 2016-02-11 08:48:11 -05:00
1 parent 5ec3cace94
commit 24e615da1e
15 files changed
+997 -733

No files matched your search

+12 -6
View File
@@ -24,12 +24,15 @@ if (Meteor.isClient) {
primary: ""
},
passwordOptions: {
requireStrongPasswords: false,
showPasswordStrengthIndicator: false
showPasswordStrengthIndicator: true,
requireRegexValidation: true
//requireStrongPasswords: false
}
});
}
// requireRegexValidation toggles regex
// reqiureStrongPasswords toggles zxcvbn
if (Meteor.isClient) {
ActiveEntry.errorMessages = new ReactiveDict('errorMessages');
@@ -56,7 +59,6 @@ ActiveEntry.verifyPassword = function (password) {
ActiveEntry.errorMessages.set('password', Session.get('passwordWarning'));
ActiveEntry.successMessages.set('password', null);
} else {
//ActiveEntry.errorMessages.set('password', 'Password present');
ActiveEntry.errorMessages.set('password', null);
ActiveEntry.successMessages.set('password', 'Password present');
}
@@ -64,11 +66,15 @@ ActiveEntry.verifyPassword = function (password) {
};
ActiveEntry.verifyConfirmPassword = function (password, confirmPassword) {
if (confirmPassword === password) {
//ActiveEntry.errorMessages.set('confirm', 'Passwords match');
// we have two different logic checks happening in this function
// would be reasonable to separate them out into separate functions
if (confirmPassword === "") {
ActiveEntry.errorMessages.set('confirm', 'Password is required');
ActiveEntry.successMessages.set('confirm', null);
} else if (confirmPassword === password) {
ActiveEntry.errorMessages.set('confirm', null);
ActiveEntry.successMessages.set('confirm', 'Passwords match');
} else{
} else {
ActiveEntry.errorMessages.set('confirm', 'Passwords do not match');
ActiveEntry.successMessages.set('confirm', null);
}
@@ -1,46 +1,59 @@
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
function getPasswordValidationSettings () {
var ActiveEntryConfiguration = Session.get('Photonic.ActiveEntry');
var validationSettings = {};
validationSettings.showPasswordStrengthIndicator = ActiveEntryConfiguration && ActiveEntryConfiguration.passwordOptions && ActiveEntryConfiguration.passwordOptions.showPasswordStrengthIndicator || false;
validationSettings.requireRegexValidation = ActiveEntryConfiguration && ActiveEntryConfiguration.passwordOptions && ActiveEntryConfiguration.passwordOptions.requireRegexValidation || false;
if (validationSettings.showPasswordStrengthIndicator) {
// Set password strength meter options
validationSettings.pwstrengthOptions = {
common: {
minChar: 8
},
ui: {
showVerdictsInsideProgressBar: true,
showStatus: true
}
};
}
// Check if codetheweb:zxcvbn is defined
if (typeof(zxcvbn) === typeof(Function)) {
validationSettings.requireStrongPasswords = ActiveEntryConfiguration && ActiveEntryConfiguration.passwordOptions && ActiveEntryConfiguration.passwordOptions.requireStrongPasswords || false;
// Set zxcvbn in pw strength meter
if (validationSettings.showPasswordStrengthIndicator) {
validationSettings.pwstrengthOptions.common.zxcvbn = passwordValidationSettings.requireStrongPasswords;
}
};
}
return validationSettings;
}
Meteor.startup(function() {
passwordValidationSettings = getPasswordValidationSettings();
});
// 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
if (passwordValidationSettings.requireStrongPasswords) {
// Check zxcvbn
var zxcvbnResult = zxcvbn(password);
if (zxcvbnResult.score > 2) {
if (zxcvbnResult && zxcvbnResult.score > 2) {
return true;
}
} else{
return false;
} else if (passwordValidationSettings.requireRegexValidation) {
// 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;
}
return false;
return true;
};
File diff suppressed because it is too large. Load diff