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

@@ -0,0 +1,40 @@
<template name="changePassword">
<div id="changePassword" class="page entryPage" style="{{getOpacityWithCorner}}">
<div class="content-scrollable">
<div class="wrapper-auth">
<div class="entryLogo" style="background-image: url('{{getLogoUrl}}')"></div>
<h1 id="changePasswordPageTitle" class="title-auth">Change Password</h1>
<div id="changePasswordPageMessage" class="subtitle-auth" style="{{getChangePasswordMessageColor}}">{{getChangePasswordMessage}}</div>
<form>
<div class="input-symbol">
<input id="changePasswordPageOldPasswordInput" type="password" name="oldPassword" placeholder="Old Password" style="{{getPasswordStyling}}" />
<span class="fa fa-lock" title="Password"></span>
</div>
<br>
<br>
<div class="input-symbol">
<input id="changePasswordPagePasswordInput" type="password" name="password" placeholder="Password" style="{{getPasswordStyling}}" />
<span class="fa fa-lock" title="Password"></span>
</div>
<br>
<br>
<div class="input-symbol">
<input id="changePasswordPagePasswordConfirmInput" type="password" name="confirm" placeholder="Confirm Password" style="{{getConfirmPasswordStyling}}" />
<span class="fa fa-lock" title="Confirm Password"></span>
</div>
<br><br>
<button id="changePasswordButton" type="submit" class="btn-gray btn-main btn-large" style="{{getButtonColor}}">Change Password</button>
<br><br>
</form>
</div>
</div>
</div>
</template>
@@ -0,0 +1,84 @@
//==========================================
Router.route('/changePassword', {
name: "changePassword",
template: "changePassword"
});
Template.changePassword.helpers({
getChangePasswordMessageColor: function (){
if (ActiveEntry.errorMessages.get('changePasswordError')) {
return "color: #a94442; background-color: #f2dede; border-color: #ebccd1;"
} else {
return "color: black;"
}
},
getChangePasswordMessage: function (){
if (ActiveEntry.errorMessages.get('changePasswordError')) {
return ActiveEntry.errorMessages.get('changePasswordError');
} else {
return Session.get('defaultSignInMessage');
}
},
getPasswordStyling: function () {
if (ActiveEntry.errorMessages.equals('password', "Password is required")) {
return "border: 1px solid #a94442";
} else if (ActiveEntry.errorMessages.equals('password', "Password is weak")) {
return "border: 1px solid #f2dede";
} else if (ActiveEntry.errorMessages.equals('password', "Password present")) {
return "border: 1px solid green";
} else {
return "border: 1px solid gray";
}
},
getConfirmPasswordStyling: function () {
if (ActiveEntry.errorMessages.equals('confirm', "Password is required")) {
return "border: 1px solid #a94442";
} else if (ActiveEntry.errorMessages.equals('confirm', "Passwords do not match")) {
return "border: 1px solid #a94442";
} else if (ActiveEntry.errorMessages.equals('confirm', "Password is weak")) {
return "border: 1px solid #f2dede";
} else if (ActiveEntry.errorMessages.equals('confirm', "Passwords match")) {
return "border: 1px solid green";
} else {
return "border: 1px solid gray";
}
}
});
Template.changePassword.events({
'change, keyup #changePasswordPagePasswordInput': function (event, template) {
var password = $('[name="password"]').val();
var confirmPassword = $('[name="confirm"]').val();
ActiveEntry.verifyPassword(password);
ActiveEntry.errorMessages.set('changePasswordError', null);
},
'change, keyup #changePasswordPagePasswordConfirmInput': function (event, template) {
var password = $('[name="password"]').val();
var confirmPassword = $('[name="confirm"]').val();
ActiveEntry.verifyConfirmPassword(password, confirmPassword);
ActiveEntry.errorMessages.set('changePasswordError', null);
},
"submit": function (event, template) {
event.preventDefault();
var oldPassword = $('[name="oldPassword"]').val();
var password = $('[name="password"]').val();
var confirmPassword = $('[name="confirm"]').val();
ActiveEntry.verifyConfirmPassword(password, confirmPassword);
ActiveEntry.errorMessages.set('changePasswordError', null);
Accounts.changePassword(oldPassword, confirmPassword, function(error) {
if (error) {
console.warn(error);
return;
}
console.log('Password changed!');
});
}
});
@@ -0,0 +1,5 @@
#changePassword{
input{
padding-left: 40px;
}
}
@@ -126,14 +126,13 @@ Template.entrySignIn.events({
ActiveEntry.signIn(emailValue, passwordValue);
event.preventDefault();
},
'keypress #entrySignIn': function(event, template) {
'keyup #entrySignIn': function(event, template) {
if(event.keyCode == 13) {
ActiveEntry.verifyEmail($("#signInPageEmailInput").val());
ActiveEntry.verifyPassword($("#signInPagePasswordInput").val());
if (!ActiveEntry.errorMessages.get('signInError') &&
ActiveEntry.successMessages.get('email') &&
ActiveEntry.successMessages.get('password')) {
$("#signInPagePasswordInput").val()) {
$("#signInToAppButton").click();
}
}
@@ -71,6 +71,8 @@ Template.entrySignUp.helpers({
if (ActiveEntry.errorMessages.equals('confirm', "Password is required")) {
return "border: 1px solid #a94442";
} else if (ActiveEntry.errorMessages.equals('confirm', "Passwords do not match")) {
return "border: 1px solid #a94442";
} else if (ActiveEntry.errorMessages.equals('confirm', "Password is weak")) {
return "border: 1px solid #f2dede";
} else if (ActiveEntry.successMessages.equals('confirm', "Passwords match")) {
return "border: 1px solid green";
@@ -133,7 +135,7 @@ Template.entrySignUp.events({
$('#signUpPageFullNameInput').val()
);
},
'keypress #entrySignUp': function(event, template) {
'keyup #entrySignUp': function(event, template) {
if(event.keyCode == 13) {
ActiveEntry.verifyFullName($("#signUpPageFullNameInput").val());
ActiveEntry.verifyEmail($("#signUpPageEmailInput").val());
@@ -153,13 +155,12 @@ Template.entrySignUp.events({
Template.entrySignUp.onRendered(function() {
// Password strength meter for password inputs
if (passwordValidationSettings.requireStrongPasswords) {
if (passwordValidationSettings.showPasswordStrengthIndicator) {
this.$('#signUpPagePasswordInput').pwstrength(passwordValidationSettings.pwstrengthOptions);
}
// Update password warning message if zxcvbn is active
if(passwordValidationSettings.showPasswordStrengthIndicator) {
// Update password warning message if zxcvbn is active and zxcvbn function is defined
if(passwordValidationSettings.requireStrongPasswords) {
Session.set('passwordWarning', 'Password is weak');
}
});