LT-103: Show error messages if username or password are invalidated

- Remove Need An Account and Forgot Password buttons for Sign In page
This commit is contained in:
Aysel Afsar 2016-03-22 17:03:13 -04:00
parent ea307b1067
commit 506ab56711
3 changed files with 80 additions and 10 deletions

View File

@ -18,14 +18,21 @@
{{#if isLDAPSet}}
<form>
{{#if ldapErrorMessages}}
<div id="errorMessages" class="list-errors">
{{#each ldapErrorMessages}}
<div class="alert alert-danger list-item">{{this}}</div>
{{/each}}
</div>
{{/if}}
<div class="input-symbol">
<input id="signInLDAPUsernameInput" type="text" name="email" placeholder="Username" style="{{getEmailValidationStyling}}" />
<input id="signInLDAPUsernameInput" type="text" name="username" placeholder="Username" style="{{getLDAPUsernameValidationStyling}}" />
<i class="fa fa-envelope-o" title="Your Email"></i>
</div>
<br><br>
<div class="input-symbol">
<input id="signInLDAPPasswordInput" type="password" name="password" placeholder="Password" style={{getPasswordValidationStyling}} />
<input id="signInLDAPPasswordInput" type="password" name="password" placeholder="Password" style={{getLDAPPasswordValidationStyling}} />
<span class="fa fa-lock" title="Password"></span>
</div>
</form>
@ -34,6 +41,7 @@
<button id="signInLDAPToAppButton" class="btn-primary btn-main btn-large" style="{{getButtonColor}}">{{getButtonText}}</button>
{{else}}
<form>
<div class="input-symbol">
<input id="signInPageEmailInput" type="text" name="email" placeholder="Your Email" style="{{getEmailValidationStyling}}" />
<i class="fa fa-envelope-o" title="Your Email"></i>
@ -49,14 +57,13 @@
<br><br>
<button id="signInToAppButton" class="btn-primary btn-main btn-large disabledButton" disabled style="{{getButtonColor}}">{{getButtonText}}</button>
<br><br>
<button id="needAnAccountButton" class="btn-gray btn-main btn-large">Need an account?</button>
<br><br>
<button id="forgotPasswordButton" class="btn-gray btn-main btn-large">Forgot password?</button>
{{/if}}
<br><br>
<button id="needAnAccountButton" class="btn-gray btn-main btn-large">Need an account?</button>
<br><br>
<button id="forgotPasswordButton" class="btn-gray btn-main btn-large">Forgot password?</button>
{{/if}}
</div>

View File

@ -66,8 +66,35 @@ Template.entrySignIn.helpers({
}
},
getLDAPUsernameValidationStyling: function() {
if (ActiveEntry.errorMessages.equals('ldapUsername', "Username is required")) {
return "border: 1px solid #a94442";
} else if (ActiveEntry.successMessages.equals('ldapUsername', "Username present")) {
return "border: 1px solid green";
} else {
return "border: 1px solid gray";
}
},
getLDAPPasswordValidationStyling: function() {
if (ActiveEntry.errorMessages.equals('ldapPassword', "Password is required")) {
return "border: 1px solid #a94442";
} else if (ActiveEntry.successMessages.equals('ldapPassword', "Password present")) {
return "border: 1px solid green";
} else {
return "border: 1px solid gray";
}
},
isLDAPSet: function() {
return Session.get('isLDAPSet');
},
ldapErrorMessages: function () {
if (ActiveEntry.errorMessages.get("ldapUsername")) {
return [ActiveEntry.errorMessages.get("ldapUsername")];
} else if(ActiveEntry.errorMessages.get("ldapPassword")) {
return [ActiveEntry.errorMessages.get("ldapPassword")];
}
return;
}
});
@ -117,6 +144,16 @@ Template.entrySignIn.events({
ActiveEntry.errorMessages.set('signInError', null);
setSignInButtonStyling();
},
'keyup, change #signInLDAPUsernameInput': function (event, template) {
var username = $('#signInLDAPUsernameInput').val();
ActiveEntry.verifyLDAPUsername(username);
ActiveEntry.errorMessages.set('signInError', null);
},
'keyup, change #signInLDAPPasswordInput': function (event, template) {
var password = $('#signInLDAPPasswordInput').val();
ActiveEntry.verifyLDAPPassword(password);
ActiveEntry.errorMessages.set('signInError', null);
},
// 'submit': function (event, template) {
// event.preventDefault();
// var emailValue = template.$('[name=email]').val();
@ -137,6 +174,8 @@ Template.entrySignIn.events({
'keyup #entrySignIn': function(event, template) {
if(event.keyCode == 13) {
$("#signInToAppButton").click();
$("#signInLDAPToAppButton").click();
}
},
'click #signInLDAPToAppButton': function(e, template) {

View File

@ -127,6 +127,26 @@ ActiveEntry.verifyFullName = function (fullName) {
}
};
ActiveEntry.verifyLDAPUsername = function(username) {
if (username === "") {
ActiveEntry.errorMessages.set("ldapUsername", "Username is required");
ActiveEntry.successMessages.set("ldapUsername", null);
} else {
ActiveEntry.errorMessages.set("ldapUsername", null);
ActiveEntry.successMessages.set("ldapUsername", "Username present");
}
};
ActiveEntry.verifyLDAPPassword = function(password) {
if (password === "") {
ActiveEntry.errorMessages.set("ldapPassword", "Password is required");
ActiveEntry.successMessages.set("ldapPassword", null);
} else {
ActiveEntry.errorMessages.set("ldapPassword", null);
ActiveEntry.successMessages.set("ldapPassword", "Password present");
}
};
ActiveEntry.signIn = function (emailValue, passwordValue){
ActiveEntry.verifyPassword(passwordValue);
@ -222,7 +242,11 @@ ActiveEntry.signIn = function (emailValue, passwordValue){
};
ActiveEntry.loginWithLDAP = function(username, password) {
if (!username || !password) {
ActiveEntry.verifyLDAPUsername(username);
ActiveEntry.verifyLDAPPassword(password);
ActiveEntry.errorMessages.set('signInError', null);
if (ActiveEntry.errorMessages.get("ldapUsername") || ActiveEntry.errorMessages.get("ldapPassword")) {
return;
}