- added optional pwstrength and zxcvbn and disabled by default.

- Reset ActiveEntry.errorMessages after active-entry buttons are clicked
- "Password is invalid" message is replaced by "Password must have at least 8 characters. It must contain at least 1 uppercase, 1 lowercase, 1 number and 1 special character."
This commit is contained in:
Aysel Afsar 2016-02-02 15:31:01 -05:00
parent d3671a5bdd
commit 236ab64add
10 changed files with 52 additions and 28 deletions

View File

@ -57,7 +57,7 @@ Template.entrySignIn.helpers({
getPasswordValidationStyling: function () { getPasswordValidationStyling: function () {
if (ActiveEntry.errorMessages.equals('password', "Password is required")) { if (ActiveEntry.errorMessages.equals('password', "Password is required")) {
return "border: 1px solid #a94442"; return "border: 1px solid #a94442";
} else if (ActiveEntry.errorMessages.equals('password', "Password is invalid")) { } else if (ActiveEntry.errorMessages.equals('password', "Password must have at least 8 characters. It must contain at least 1 uppercase, 1 lowercase, 1 number and 1 special character.")) {
return "border: 1px solid #f2dede"; return "border: 1px solid #f2dede";
} else if (ActiveEntry.errorMessages.equals('password', "Password present")) { } else if (ActiveEntry.errorMessages.equals('password', "Password present")) {
return "border: 1px solid green"; return "border: 1px solid green";
@ -77,10 +77,12 @@ Template.entrySignIn.events({
}, },
'click #forgotPasswordButton': function (event) { 'click #forgotPasswordButton': function (event) {
event.preventDefault(); event.preventDefault();
ActiveEntry.reset();
Router.go('/forgotPassword'); Router.go('/forgotPassword');
}, },
"click #needAnAccountButton": function (event) { "click #needAnAccountButton": function (event) {
event.preventDefault(); event.preventDefault();
ActiveEntry.reset();
Router.go('/entrySignUp'); Router.go('/entrySignUp');
}, },
'keyup input[name="email"]': function (event, template) { 'keyup input[name="email"]': function (event, template) {
@ -116,6 +118,7 @@ Template.entrySignIn.events({
// }, // },
'click #signInToAppButton': function (event, template){ 'click #signInToAppButton': function (event, template){
console.log('click #signInToAppButton'); console.log('click #signInToAppButton');
ActiveEntry.reset();
// var emailValue = template.$('[name=email]').val(); // var emailValue = template.$('[name=email]').val();
// var passwordValue = template.$('[name=password]').val(); // var passwordValue = template.$('[name=password]').val();
var emailValue = template.$('#signInPageEmailInput').val(); var emailValue = template.$('#signInPageEmailInput').val();

View File

@ -33,10 +33,7 @@ Template.entrySignUp.helpers({
entryErrorMessages: function () { entryErrorMessages: function () {
var errorMessages = []; var errorMessages = [];
Object.keys(ActiveEntry.errorMessages.all()).forEach(function(key) { Object.keys(ActiveEntry.errorMessages.all()).forEach(function(key) {
if (key !== "signInError" && ActiveEntry.errorMessages.get(key) && if (key !== "signInError" && ActiveEntry.errorMessages.get(key)) {
ActiveEntry.errorMessages.get(key) !== "null" &&
ActiveEntry.errorMessages.get(key) !== undefined &&
ActiveEntry.errorMessages.get(key) !== null) {
errorMessages.push(ActiveEntry.errorMessages.get(key)); errorMessages.push(ActiveEntry.errorMessages.get(key));
} }
}); });
@ -64,7 +61,7 @@ Template.entrySignUp.helpers({
getPasswordStyling: function () { getPasswordStyling: function () {
if (ActiveEntry.errorMessages.equals('password', "Password is required")) { if (ActiveEntry.errorMessages.equals('password', "Password is required")) {
return "border: 1px solid #a94442"; return "border: 1px solid #a94442";
} else if (ActiveEntry.errorMessages.equals('password', "Password is invalid")) { } else if (ActiveEntry.errorMessages.equals('password', "Password must have at least 8 characters. It must contain at least 1 uppercase, 1 lowercase, 1 number and 1 special character.")) {
return "border: 1px solid #f2dede"; return "border: 1px solid #f2dede";
} else if (ActiveEntry.successMessages.equals('password', "Password present")) { } else if (ActiveEntry.successMessages.equals('password', "Password present")) {
return "border: 1px solid green"; return "border: 1px solid green";
@ -75,7 +72,7 @@ Template.entrySignUp.helpers({
getConfirmPasswordStyling: function () { getConfirmPasswordStyling: function () {
if (ActiveEntry.errorMessages.equals('confirm', "Password is required")) { if (ActiveEntry.errorMessages.equals('confirm', "Password is required")) {
return "border: 1px solid #a94442"; return "border: 1px solid #a94442";
} else if (ActiveEntry.errorMessages.equals('confirm', "Password is invalid")) { } else if (ActiveEntry.errorMessages.equals('confirm', "Passwords do not match")) {
return "border: 1px solid #f2dede"; return "border: 1px solid #f2dede";
} else if (ActiveEntry.successMessages.equals('confirm', "Passwords match")) { } else if (ActiveEntry.successMessages.equals('confirm', "Passwords match")) {
return "border: 1px solid green"; return "border: 1px solid green";
@ -98,6 +95,7 @@ Template.entrySignUp.helpers({
Template.entrySignUp.events({ Template.entrySignUp.events({
"click #signUpPageSignInButton": function (event) { "click #signUpPageSignInButton": function (event) {
ActiveEntry.reset();
event.preventDefault(); event.preventDefault();
Router.go('/entrySignIn'); Router.go('/entrySignIn');
}, },
@ -133,9 +131,7 @@ Template.entrySignUp.events({
'click #signUpPageJoinNowButton': function (event, template) { 'click #signUpPageJoinNowButton': function (event, template) {
event.preventDefault(); event.preventDefault();
ActiveEntry.errorMessages.set('signInError', null); ActiveEntry.reset();
//ActiveEntry.verifyPassword(event, template);
var newUser = { var newUser = {
fullName: template.$('[name="fullName"]').val(), fullName: template.$('[name="fullName"]').val(),
email: template.$('[name="email"]').val(), email: template.$('[name="email"]').val(),
@ -154,5 +150,8 @@ Template.entrySignUp.events({
Template.entrySignUp.onRendered(function() { Template.entrySignUp.onRendered(function() {
// Password strength meter for password inputs // Password strength meter for password inputs
this.$(':password').pwstrength(pwstrengthOptions); console.log(passwordValidationSettings)
if (passwordValidationSettings.usePwstrength) {
this.$('#signUpPagePasswordInput').pwstrength(passwordValidationSettings.pwstrengthOptions);
}
}); });

View File

@ -6,6 +6,7 @@
} }
} }
.progress { #entrySignUp .progress{
height: 5px; height: 5px;
margin-bottom: 1px
} }

View File

@ -51,7 +51,7 @@ ActiveEntry.verifyPassword = function (password) {
ActiveEntry.errorMessages.set('password', 'Password is required'); ActiveEntry.errorMessages.set('password', 'Password is required');
ActiveEntry.successMessages.set('password', null); ActiveEntry.successMessages.set('password', null);
} else if (!validatePassword(password)) { } else if (!validatePassword(password)) {
ActiveEntry.errorMessages.set('password', 'Password is invalid'); 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.');
ActiveEntry.successMessages.set('password', null); ActiveEntry.successMessages.set('password', null);
} else { } else {
//ActiveEntry.errorMessages.set('password', 'Password present'); //ActiveEntry.errorMessages.set('password', 'Password present');
@ -65,6 +65,9 @@ ActiveEntry.verifyConfirmPassword = function (password, confirmPassword) {
//ActiveEntry.errorMessages.set('confirm', 'Passwords match'); //ActiveEntry.errorMessages.set('confirm', 'Passwords match');
ActiveEntry.errorMessages.set('confirm', null); ActiveEntry.errorMessages.set('confirm', null);
ActiveEntry.successMessages.set('confirm', 'Passwords match'); ActiveEntry.successMessages.set('confirm', 'Passwords match');
} else{
ActiveEntry.errorMessages.set('confirm', 'Passwords do not match');
ActiveEntry.successMessages.set('confirm', null);
} }
}; };
ActiveEntry.verifyEmail = function (email) { ActiveEntry.verifyEmail = function (email) {
@ -115,6 +118,7 @@ ActiveEntry.signUp = function (emailValue, passwordValue, confirmPassword, fullN
ActiveEntry.verifyPassword(passwordValue); ActiveEntry.verifyPassword(passwordValue);
ActiveEntry.verifyConfirmPassword(passwordValue, confirmPassword); ActiveEntry.verifyConfirmPassword(passwordValue, confirmPassword);
ActiveEntry.verifyFullName(fullName); ActiveEntry.verifyFullName(fullName);
ActiveEntry.errorMessages.set('signInError', null);
var errorIsFound = false; var errorIsFound = false;
Object.keys(ActiveEntry.errorMessages.keys).forEach(function(key) { Object.keys(ActiveEntry.errorMessages.keys).forEach(function(key) {
@ -124,7 +128,6 @@ ActiveEntry.signUp = function (emailValue, passwordValue, confirmPassword, fullN
}); });
if(errorIsFound) { if(errorIsFound) {
// TODO: Show error messages
return; return;
} }
@ -159,10 +162,12 @@ ActiveEntry.signUp = function (emailValue, passwordValue, confirmPassword, fullN
// }); // });
}; };
ActiveEntry.signOut = function (){ ActiveEntry.signOut = function (){
ActiveEntry.reset();
Meteor.logout(); Meteor.logout();
}; };
ActiveEntry.reset = function (){ ActiveEntry.reset = function (){
ActiveEntry.errorMessages.set('signInError', false);
ActiveEntry.errorMessages.set('fullName', false); ActiveEntry.errorMessages.set('fullName', false);
ActiveEntry.errorMessages.set('email', false); ActiveEntry.errorMessages.set('email', false);
ActiveEntry.errorMessages.set('confirm', false); ActiveEntry.errorMessages.set('confirm', false);

View File

@ -1,13 +1,18 @@
pwstrengthOptions = { passwordValidationSettings = {};
common: {
minChar: 8, Meteor.startup(function(){
zxcvbn: true passwordValidationSettings.usePwstrength = Meteor.settings.public.usePwstrength;
}, passwordValidationSettings.pwstrengthOptions = {
ui: { common: {
showVerdictsInsideProgressBar: true, minChar: 8,
showStatus: true 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 // 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) { validatePassword = function(password) {

View File

@ -61,7 +61,7 @@ describe('clinical:active-entry', function () {
expect(ActiveEntry.errorMessages.get('password')).to.equal("Password is required"); expect(ActiveEntry.errorMessages.get('password')).to.equal("Password is required");
ActiveEntry.verifyPassword('kittens'); ActiveEntry.verifyPassword('kittens');
expect(ActiveEntry.errorMessages.get('password')).to.equal("Password is invalid"); expect(ActiveEntry.errorMessages.get('password')).to.equal("Password must have at least 8 characters. It must contain at least 1 uppercase, 1 lowercase, 1 number and 1 special character.");
ActiveEntry.verifyPassword('K1tt#ns123'); ActiveEntry.verifyPassword('K1tt#ns123');
expect(ActiveEntry.successMessages.get('password')).to.equal("Password present"); expect(ActiveEntry.successMessages.get('password')).to.equal("Password present");
@ -71,6 +71,9 @@ describe('clinical:active-entry', function () {
// ActiveEntry.verifyConfirmPassword // ActiveEntry.verifyConfirmPassword
it('Password match validation confirms that two passwords are the same.', function () { it('Password match validation confirms that two passwords are the same.', function () {
return client.execute(function (a) { return client.execute(function (a) {
ActiveEntry.verifyConfirmPassword('K1tt#kittens', 'kittens');
expect(ActiveEntry.successMessages.get('confirm')).to.equal("Passwords do not match");
ActiveEntry.verifyConfirmPassword('K1tt#ns123', 'K1tt#ns123'); ActiveEntry.verifyConfirmPassword('K1tt#ns123', 'K1tt#ns123');
expect(ActiveEntry.successMessages.get('confirm')).to.equal("Passwords match"); expect(ActiveEntry.successMessages.get('confirm')).to.equal("Passwords match");
}); });

View File

@ -22,6 +22,8 @@
"staleSessionInactivityTimeout": 1800000, "staleSessionInactivityTimeout": 1800000,
"staleSessionHeartbeatInterval": 180000, "staleSessionHeartbeatInterval": 180000,
"staleSessionPurgeInterval": 60000, "staleSessionPurgeInterval": 60000,
"staleSessionActivityEvents": "mousemove click keydown" "staleSessionActivityEvents": "mousemove click keydown",
"usePwstrength": false,
"useZxcvbn": false
} }
} }

View File

@ -20,6 +20,8 @@
"staleSessionInactivityTimeout": 1800000, "staleSessionInactivityTimeout": 1800000,
"staleSessionHeartbeatInterval": 180000, "staleSessionHeartbeatInterval": 180000,
"staleSessionPurgeInterval": 60000, "staleSessionPurgeInterval": 60000,
"staleSessionActivityEvents": "mousemove click keydown" "staleSessionActivityEvents": "mousemove click keydown",
"usePwstrength": false,
"useZxcvbn": false
} }
} }

View File

@ -21,6 +21,8 @@
"staleSessionInactivityTimeout": 1800000, "staleSessionInactivityTimeout": 1800000,
"staleSessionHeartbeatInterval": 180000, "staleSessionHeartbeatInterval": 180000,
"staleSessionPurgeInterval": 60000, "staleSessionPurgeInterval": 60000,
"staleSessionActivityEvents": "mousemove click keydown" "staleSessionActivityEvents": "mousemove click keydown",
"usePwstrength": false,
"useZxcvbn": false
} }
} }

View File

@ -20,6 +20,8 @@
"staleSessionInactivityTimeout": 1800000, "staleSessionInactivityTimeout": 1800000,
"staleSessionHeartbeatInterval": 180000, "staleSessionHeartbeatInterval": 180000,
"staleSessionPurgeInterval": 60000, "staleSessionPurgeInterval": 60000,
"staleSessionActivityEvents": "mousemove click keydown" "staleSessionActivityEvents": "mousemove click keydown",
"usePwstrength": false,
"useZxcvbn": false
} }
} }