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:
1 parent
5ec3cace94
commit
24e615da1e
15 files changed
+997
-733
No files matched your search
@@ -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;
|
||||
};
|
||||
Reference in new issue
Block a user