ohif-viewer/Packages/active-entry/components/entrySignIn/entrySignIn.js
Aysel Afsar eb32e1771f LT-97: Add requireRegexValidation and requireStrongPasswords properties under passwordOptions which is under passwordOptions.
- requireRegexValidation toggles whether or not password validation is controlled by regular expression
- requireStrongPasswords toggles whether password validation is controlled by zxcvbn package
LT-104: User account shall be locked after 5 failed attempts
- "failedAttemptsLimit" property which is under passwordOptions in ActiveEntry configuration object sets number of failed attempts count to lock user account, it is set 5 as default
LT-99: Passwords shall use password history of 6
- "passwordHistoryCount" property which is under passwordOptions in ActiveEntry configuration object sets count of last passwords that is not used to reset password
- Show error messages in changePassword template
- Make signIn button disabled if inputs are not validated
2016-02-14 17:03:00 -05:00

157 lines
5.0 KiB
JavaScript
Executable File

// REFACTOR: Move to ActiveRecord object
Session.set("defaultSignInMessage", "Improve your clinical practice with checklists.");
//==================================================================================================
// ROUTER
Router.route('/entrySignIn', {
template: 'entrySignIn',
name: 'entrySignIn'
});
Router.route('/sign-in', {
template: 'entrySignIn',
name: 'signInRoute'
});
//==================================================================================================
// COMPONENT OUTPUTS
Template.entrySignIn.helpers({
getSignInMessageColor: function (){
if (ActiveEntry.errorMessages.get('signInError')) {
return "color: #a94442; background-color: #f2dede; border-color: #ebccd1;"
} else {
return "color: black;"
}
},
getSignInMessage: function (){
if (ActiveEntry.errorMessages.get('signInError')) {
return ActiveEntry.errorMessages.get('signInError');
} else {
return Session.get('defaultSignInMessage');
}
},
getButtonText: function () {
return "Sign In";
// if (ActiveEntry.errorMessages.get('signInError')){
// return ActiveEntry.errorMessages.get('signInError');
// } else {
// return "Sign In";
// }
},
getEmailValidationStyling: function () {
if (ActiveEntry.errorMessages.equals('email', "Email is required")) {
return "border: 1px solid #a94442";
} else if (ActiveEntry.errorMessages.equals('email', "Email is poorly formatted")) {
return "border: 1px solid #f2dede";
} else if (ActiveEntry.successMessages.equals('email', "Email present")) {
return "border: 1px solid green";
} else {
return "border: 1px solid gray";
}
},
getPasswordValidationStyling: function () {
if (ActiveEntry.errorMessages.equals('password', "Password is required")) {
return "border: 1px solid #a94442";
} else if (ActiveEntry.errorMessages.equals('password', Session.get('passwordWarning'))) {
return "border: 1px solid #f2dede";
} else if (ActiveEntry.successMessages.equals('password', "Password present")) {
return "border: 1px solid green";
} else {
return "border: 1px solid gray";
}
}
});
//==================================================================================================
// COMPONENT OUTPUTS
Template.entrySignIn.events({
'click #logoutButton': function () {
Meteor.logout();
},
'click #forgotPasswordButton': function (event) {
event.preventDefault();
ActiveEntry.reset();
Router.go('/forgotPassword');
},
"click #needAnAccountButton": function (event) {
event.preventDefault();
ActiveEntry.reset();
Router.go('/entrySignUp');
},
'keyup input[name="email"]': function (event, template) {
var email = $('input[name="email"]').val();
ActiveEntry.verifyEmail(email);
ActiveEntry.errorMessages.set('signInError', null);
setSignInButtonStyling();
},
'change input[name="email"]': function (event, template) {
var email = $('input[name="email"]').val();
ActiveEntry.verifyEmail(email);
ActiveEntry.errorMessages.set('signInError', null);
setSignInButtonStyling();
},
'keyup #signInPagePasswordInput': function (event, template) {
var password = $('input[name="password"]').val();
ActiveEntry.verifyPassword(password);
ActiveEntry.errorMessages.set('signInError', null);
setSignInButtonStyling();
},
'change #signInPagePasswordInput': function (event, template) {
var password = $('input[name="password"]').val();
ActiveEntry.verifyPassword(password);
ActiveEntry.errorMessages.set('signInError', null);
setSignInButtonStyling();
},
// 'submit': function (event, template) {
// event.preventDefault();
// var emailValue = template.$('[name=email]').val();
// var passwordValue = template.$('[name=password]').val();
//
// ActiveEntry.signIn(emailValue, passwordValue);
// },
'click #signInToAppButton': function (event, template){
ActiveEntry.reset();
// var emailValue = template.$('[name=email]').val();
// var passwordValue = template.$('[name=password]').val();
var emailValue = template.$('#signInPageEmailInput').val();
var passwordValue = template.$('#signInPagePasswordInput').val();
ActiveEntry.signIn(emailValue, passwordValue);
event.preventDefault();
},
'keyup #entrySignIn': function(event, template) {
if(event.keyCode == 13) {
$("#signInToAppButton").click();
}
}
});
//==================================================================================================
// Sets SignInButton Styling according to email and password fields
function setSignInButtonStyling() {
var signInToAppButton = $("#signInToAppButton");
if ($("#signInPagePasswordInput").val() && ActiveEntry.successMessages.get('email')) {
// Set button as enable
signInToAppButton.removeClass("disabledButton");
signInToAppButton.attr("disabled", false);
} else {
signInToAppButton.addClass("disabledButton");
signInToAppButton.attr("disabled", true);
}
}