var application = new shnakkyDoodle.core.application(); var user = new shnakkyDoodle.core.user(); var page = new shnakkyDoodle.core.page(); var core = shnakkyDoodle.core; var messaging = new shnakkyDoodle.dashboard.messaging(); var urlParams; var vals=""; var email=""; var first_name=""; var sur_name=""; var email_address=""; var prepopfirstname=""; var prepopsurname=""; var prepopemailaddress=""; var prepopulate=""; var spinner = null; var tops=""; debugger; function validateEmail(email) { var re = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/; return re.test(String(email).toLowerCase()); } $(function() { }); function showSpinner(){ var opts = { lines: 13 // The number of lines to draw , length: 18 // The length of each line , width: 14 // The line thickness , radius: 42 // The radius of the inner circle , scale: 1 // Scales overall size of the spinner , corners: 1 // Corner roundness (0..1) , color: '#000' // #rgb or #rrggbb or array of colors , opacity: 0.20 // Opacity of the lines , rotate: 0 // The rotation offset , direction: 1 // 1: clockwise, -1: counterclockwise , speed: 1 // Rounds per second , trail: 80 // Afterglow percentage , fps: 20 // Frames per second when using setTimeout() as a fallback for CSS , zIndex: 2e9 // The z-index (defaults to 2000000000) , className: 'spinner' // The CSS class to assign to the spinner , top: '40%' // Top position relative to parent , left: '50%' // Left position relative to parent , shadow: true // Whether to render a shadow , hwaccel: false // Whether to use hardware acceleration }; spinner = new Spinner(opts).spin(document.getElementById('maincontent')); } /** * hide the process bar */ function hideProgress(){ setTimeout(function(){ spinner.stop(); }, 200); } function authenticateredirect(){ debugger; window.location.reload(); } function authenticatevalidateuser(){ debugger; showSpinner(); var firstname = $("#firstname").val(); var surname= $("#surname").val(); var emailaddress = $("#inputemailaddress").val(); var inputrepeatemailaddress = $("#inputrepeatemailaddress").val(); var isValid = true; if(emailaddress != ""){ if(!validateEmail(emailaddress)){ $("#validateemail").show(); $("#uservalidate").hide(); $("#emailsnotvalid").hide(); return false; } } if(emailaddress != inputrepeatemailaddress){ $("#emailsnotvalid").show(); $("#uservalidate").hide(); $("#validateemail").hide(); return false; } if(firstname == ""){ isValid = false; } if(surname == ""){ isValid = false; } if(emailaddress == ""){ isValid = false; } if(inputrepeatemailaddress == ""){ isValid = false; } if(!isValid){ $("#uservalidate").show(); return false; }else{ $("#uservalidate").hide(); } var messagerequest = {}; messagerequest.authentication = {}; messagerequest.authentication = {'gatewaytoken': vals }; messagerequest.firstname = $("#firstname").val(); messagerequest.surname = $("#surname").val(); messagerequest.emailaddress = $("#inputemailaddress").val(); messagerequest.usr = vals; messagerequest.email = email; $.ajax({ type : "POST", url : "/authentication/rest/login/usercreateotp", jsonpCallback : "authenticate_user", data: JSON.stringify(messagerequest), beforeSend : function() { $("#maincontent").show(); }, success : function(data) { debugger; var info = data; if(info.olddetails === "true" && info.userexist === "false"){ $("#loginfailedmessage").hide(); $("#loggedin").hide(); $("#loginbutton").hide(); $("#popup").hide(); $("#popupbutton").hide(); $("#userdetails").hide(); $("#userdetailsbutton").hide(); $("#emailsnotvalid").hide(); $("#uservalidate").hide(); $("#validateemail").hide(); $("#forgot").hide(); $("#userexists").hide(); $("#useronetimepin").show(); $("#userinputotp").focus(); $("#otpbuttonvalidate").show(); $("#textforOTP").html("We have sent a one time pin (OTP) to " + emailaddress + " please input this below..."); vals = info.usr; email = info.email; email_address = info.emailaddress; first_name = info.firstname; sur_name = info.surname; } else { if(info.olddetails === "true"){ $("#loginfailedmessage").hide(); $("#loggedin").hide(); $("#loginbutton").hide(); $("#popup").hide(); $("#popupbutton").hide(); $("#userdetails").hide(); $("#userdetailsbutton").hide(); $("#emailsnotvalid").hide(); $("#uservalidate").hide(); $("#validateemail").hide(); $("#forgot").hide(); $("#onetimepin").hide(); $("#useronetimepin").hide(); $("#otpbuttonvalidate").hide(); $("#userexists").hide(); $("#passwordvalidation").show(); $("#password").focus(); $("#passwordvalidationbutton").show(); vals = info.usr; email = info.email; email_address = info.emailaddress; first_name = info.firstname; sur_name = info.surname; } } }, complete : function() { hideProgress(); }, error : function(error) { if(error.responseText.includes("408")){ displayOverlay("Your session has timed out and you will be logged out automatically.
Please log in again in order to continue."); } if(error.responseJSON === "userexists"){ $("#userexists").show("slow", function(){}); }else{ $("#loginfailedmessage").show("slow", function(){}); } user.add("gatewaytoken", "",{path:"/",expires:-1}); } }); } function authenticateuserotp(){ debugger; showSpinner(); var messagerequest = {}; messagerequest.authentication = {}; messagerequest.authentication = {'gatewaytoken': vals }; messagerequest.otp = $("#userinputotp").val(); messagerequest.usr = vals; messagerequest.email = email; messagerequest.emailaddress = email_address; messagerequest.firstname = first_name; messagerequest.surname = sur_name; // "otp=" + encodeURIComponent($("#userinputotp").val()) + "&usr=" + encodeURIComponent(vals), if($("#userinputotp").val() == ""){ return false; } $.ajax({ type : "POST", url : "/authentication/rest/login/validateotp", jsonpCallback : "authenticate_user", data:JSON.stringify(messagerequest), beforeSend : function() { $("#maincontent").show(); }, success : function(data) { debugger; var info = data; if(info.olddetails === "true"){ $("#loginfailedmessage").hide(); $("#loggedin").hide(); $("#loginbutton").hide(); $("#popup").hide(); $("#popupbutton").hide(); $("#userdetails").hide(); $("#userdetailsbutton").hide(); $("#emailsnotvalid").hide(); $("#uservalidate").hide(); $("#validateemail").hide(); $("#forgot").hide(); $("#onetimepin").hide(); $("#useronetimepin").hide(); $("#userexists").hide(); $("#otpbuttonvalidate").hide(); $("#otpfailed").hide(); $("#passwordvalidation").show(); $("#password").focus(); $("#passwordvalidationbutton").show(); vals = info.usr; email = info.email; email_address = info.emailaddress; first_name = info.firstname; sur_name = info.surname; } }, complete : function() { hideProgress(); }, error : function(error) { if(error.responseText.includes("408")){ displayOverlay("Your session has timed out and you will be logged out automatically.
Please log in again in order to continue."); } $("#otpfailed").show("slow", function(){}); user.add("gatewaytoken", "",{path:"/",expires:-1}); } }); } function authenticatepasswordvalidate(){ var p = $("#password").val(), errors = []; var repeatpassword = $("#repeatpassword").val(); var checkSpecial = /[*@!#%&()^~{}]+/.test(p), checkUpper = /[A-Z]+/.test(p), checkLower = /[a-z]+/.test(p); if (checkUpper && checkLower && checkSpecial) { }else{ errors.push("Password does not meet criteria."); } if(p != repeatpassword){ errors.push("Password does not match."); } if(p === ""){ errors.push("Password cannot be empty"); } if (errors.length > 0) { $("#invalidpassword").show(); $("#passwordinvalid").html(errors.join("\n")); return false; } var messagerequest = {}; messagerequest.authentication = {}; messagerequest.authentication = {'gatewaytoken': vals }; messagerequest.password = $("#password").val(); messagerequest.email = email; messagerequest.emailaddress = email_address; messagerequest.firstname = first_name; messagerequest.surname = sur_name; $.ajax({ type : "POST", url : "/authentication/rest/login/validatepassword", jsonpCallback : "authenticate_user", data: JSON.stringify(messagerequest), beforeSend : function() { $("#maincontent").show(); }, success : function(data) { debugger; var info = data; if(info.success === "true"){ $("#loginfailedmessage").hide(); $("#loggedin").hide(); $("#loginbutton").hide(); $("#popup").hide(); $("#popupbutton").hide(); $("#userdetails").hide(); $("#userdetailsbutton").hide(); $("#emailsnotvalid").hide(); $("#uservalidate").hide(); $("#forgot").hide(); $("#validateemail").hide(); $("#onetimepin").hide(); $("#useronetimepin").hide(); $("#otpbuttonvalidate").hide(); $("#passwordvalidation").hide(); $("#userexists").hide(); $("#passwordvalidationbutton").hide(); $("#invalidpassword").hide(); $("#success").show(); $("#successbutton").show(); $('#entersuccess').focus(); } }, complete : function() { hideProgress(); }, error : function(error) { if(error.responseText.includes("408")){ displayOverlay("Your session has timed out and you will be logged out automatically.
Please log in again in order to continue."); } $("#loginfailedmessage").show("slow", function(){}); user.add("gatewaytoken", "",{path:"/",expires:-1}); } }); } $("#expiredpassword, #expiredrepeatpassword").on('keypress',function(e) { if(e.keyCode == 13){ var p = $("#expiredpassword").val(), errors = []; var repeatpassword = $("#expiredrepeatpassword").val(); var checkSpecial = /[*@!#%&()^~{}]+/.test(p), checkUpper = /[A-Z]+/.test(p), checkLower = /[a-z]+/.test(p); if (checkUpper && checkLower && checkSpecial) { }else{ errors.push("Password does not meet criteria."); } if(p != repeatpassword){ errors.push("Password does not match."); } if(p === ""){ errors.push("Password cannot be empty."); } if (errors.length > 0) { $("#invalidpassword").show(); $("#passwordinvalid").html(errors.join("\n")); return false; } var messageexpiredpasswordrequest = {}; messageexpiredpasswordrequest.authentication = {}; messageexpiredpasswordrequest.authentication = {'gatewaytoken': vals }; messageexpiredpasswordrequest.password = $("#expiredpassword").val(); messageexpiredpasswordrequest.email = email; $.ajax({ type : "POST", url : "/authentication/rest/login/expiredvalidatepassword", jsonpCallback : "authenticate_user", data: JSON.stringify(messageexpiredpasswordrequest), beforeSend : function() { $("#maincontent").show(); }, success : function(data) { debugger; var info = data; if(info.passwordmatch === "true"){ $("#loginfailedmessage").hide(); $("#invalidpassword").hide(); $("#expiredmatchedpassword").show(); $("#expiredpasswordinvalid").html("Password already exists.
Please choose another."); } if(info.success === "true"){ $("#loginfailedmessage").hide(); $("#expiredmatchedpassword").hide(); $("#loginblockedmessage").hide(); $("#forgotpasswordfailedmessage").hide(); $("#invalidpassword").hide(); $("#forgotpasswordvalidation").hide(); $("#forgotpasswordvalidationbutton").hide(); $("#forgotpasswordsuccess").hide(); $('#expiredpasswordpopup').hide(); $('#expiredotpbutton').hide(); $('#expiredpasswordvalidation').hide(); $('#exipredotpbuttonvalidate').hide(); $('#expiredpopupbutton').hide(); $("#expiredpasswordvalidationbutton").hide(); $("#expiredmatchedpassword").hide(); $("#success").show(); $("#successbutton").show(); $('#entersuccess').focus(); } }, complete : function() { hideProgress(); }, error : function(error) { if(error.responseText.includes("408")){ displayOverlay("Your session has timed out and you will be logged out automatically.
Please log in again in order to continue."); } $("#loginfailedmessage").show("slow", function(){}); user.add("gatewaytoken", "",{path:"/",expires:-1}); } }); } }); function authenticateexpiredpasswordvalidate(){ showSpinner(); var p = $("#expiredpassword").val(), errors = []; var repeatpassword = $("#expiredrepeatpassword").val(); var checkSpecial = /[*@!#%&()^~{}]+/.test(p), checkUpper = /[A-Z]+/.test(p), checkLower = /[a-z]+/.test(p); if (checkUpper && checkLower && checkSpecial) { }else{ errors.push("Password does not meet criteria."); } if(p != repeatpassword){ errors.push("Password does not match."); } if(p === ""){ errors.push("Password cannot be empty."); } if (errors.length > 0) { $("#invalidpassword").show(); $("#passwordinvalid").html(errors.join("\n")); return false; } var messageexpiredpasswordrequest = {}; messageexpiredpasswordrequest.authentication = {}; messageexpiredpasswordrequest.authentication = {'gatewaytoken': vals }; messageexpiredpasswordrequest.password = $("#expiredpassword").val(); messageexpiredpasswordrequest.email = email; $.ajax({ type : "POST", url : "/authentication/rest/login/expiredvalidatepassword", jsonpCallback : "authenticate_user", data: JSON.stringify(messageexpiredpasswordrequest), beforeSend : function() { $("#maincontent").show(); }, success : function(data) { debugger; var info = data; if(info.passwordmatch === "true"){ $("#loginfailedmessage").hide(); $("#invalidpassword").hide(); $("#expiredmatchedpassword").show(); $("#expiredpasswordinvalid").html("Password already exists.
Please choose another."); } if(info.success === "true"){ $("#loginfailedmessage").hide(); $("#expiredmatchedpassword").hide(); $("#loginblockedmessage").hide(); $("#forgotpasswordfailedmessage").hide(); $("#invalidpassword").hide(); $("#forgotpasswordvalidation").hide(); $("#forgotpasswordvalidationbutton").hide(); $("#forgotpasswordsuccess").hide(); $('#expiredpasswordpopup').hide(); $('#expiredotpbutton').hide(); $('#expiredpasswordvalidation').hide(); $('#exipredotpbuttonvalidate').hide(); $('#expiredpopupbutton').hide(); $("#expiredpasswordvalidationbutton").hide(); $("#expiredmatchedpassword").hide(); $("#success").show(); $("#successbutton").show(); $('#entersuccess').focus(); } }, complete : function() { hideProgress(); }, error : function(error) { if(error.responseText.includes("408")){ displayOverlay("Your session has timed out and you will be logged out automatically.
Please log in again in order to continue."); } $("#loginfailedmessage").show("slow", function(){}); user.add("gatewaytoken", "",{path:"/",expires:-1}); } }); } $("#firstname").keyup(function(event) { var firstname = $("#firstname").val(); if(firstname !== ""){ $("#labelfirstname").show(); }else{ $("#labelfirstname").hide(); } }); $("#userinputotp").on('keypress',function(e) { var userinputotp = $("#userinputotp").val(); if(e.keyCode == 13){ if(userinputotp === "" ){ $("#loginfailedmessage").show("slow", function(){}); return false; }else { var messagerequest = {}; messagerequest.authentication = {}; messagerequest.authentication = {'gatewaytoken': vals }; messagerequest.otp = $("#userinputotp").val(); messagerequest.usr = vals; messagerequest.email = email; messagerequest.emailaddress = email_address; messagerequest.firstname = first_name; messagerequest.surname = sur_name; // "otp=" + encodeURIComponent($("#userinputotp").val()) + "&usr=" + encodeURIComponent(vals), if($("#userinputotp").val() == ""){ return false; } $.ajax({ type : "POST", url : "/authentication/rest/login/validateotp", jsonpCallback : "authenticate_user", data:JSON.stringify(messagerequest), beforeSend : function() { $("#maincontent").show(); }, success : function(data) { debugger; var info = data; if(info.olddetails === "true"){ hideProgress(); $("#loginfailedmessage").hide(); $("#loggedin").hide(); $("#loginbutton").hide(); $("#popup").hide(); $("#popupbutton").hide(); $("#userdetails").hide(); $("#userdetailsbutton").hide(); $("#emailsnotvalid").hide(); $("#uservalidate").hide(); $("#validateemail").hide(); $("#forgot").hide(); $("#onetimepin").hide(); $("#useronetimepin").hide(); $("#userexists").hide(); $("#otpbuttonvalidate").hide(); $("#otpfailed").hide(); $("#passwordvalidation").show(); $("#password").focus(); $("#passwordvalidationbutton").show(); vals = info.usr; email = info.email; email_address = info.emailaddress; first_name = info.firstname; sur_name = info.surname; } }, complete : function() { hideProgress(); }, error : function(error) { if(error.responseText.includes("408")){ displayOverlay("Your session has timed out and you will be logged out automatically.
Please log in again in order to continue."); } $("#otpfailed").show("slow", function(){}); user.add("gatewaytoken", "",{path:"/",expires:-1}); } }); } } }); $("#password, #repeatpassword").on('keypress',function(e) { if(e.keyCode == 13){ var p = $("#password").val(), errors = []; var repeatpassword = $("#repeatpassword").val(); var checkSpecial = /[*@!#%&()^~{}]+/.test(p), checkUpper = /[A-Z]+/.test(p), checkLower = /[a-z]+/.test(p); if (checkUpper && checkLower && checkSpecial) { }else{ errors.push("Password does not meet criteria."); } if(p != repeatpassword){ errors.push("Password does not match."); } if(p === ""){ errors.push("Password cannot be empty"); } if (errors.length > 0) { $("#invalidpassword").show(); $("#passwordinvalid").html(errors.join("\n")); return false; } var messagerequest = {}; messagerequest.authentication = {}; messagerequest.authentication = {'gatewaytoken': vals }; messagerequest.password = $("#password").val(); messagerequest.email = email; messagerequest.emailaddress = email_address; messagerequest.firstname = first_name; messagerequest.surname = sur_name; $.ajax({ type : "POST", url : "/authentication/rest/login/validatepassword", jsonpCallback : "authenticate_user", data: JSON.stringify(messagerequest), beforeSend : function() { $("#maincontent").show(); }, success : function(data) { debugger; var info = data; if(info.success === "true"){ $("#loginfailedmessage").hide(); $("#loggedin").hide(); $("#loginbutton").hide(); $("#popup").hide(); $("#popupbutton").hide(); $("#userdetails").hide(); $("#userdetailsbutton").hide(); $("#emailsnotvalid").hide(); $("#uservalidate").hide(); $("#forgot").hide(); $("#validateemail").hide(); $("#onetimepin").hide(); $("#useronetimepin").hide(); $("#otpbuttonvalidate").hide(); $("#passwordvalidation").hide(); $("#userexists").hide(); $("#passwordvalidationbutton").hide(); $("#invalidpassword").hide(); $("#success").show(); $("#successbutton").show(); $('#entersuccess').focus(); } }, complete : function() { hideProgress(); }, error : function(error) { if(error.responseText.includes("408")){ displayOverlay("Your session has timed out and you will be logged out automatically.
Please log in again in order to continue."); } $("#loginfailedmessage").show("slow", function(){}); user.add("gatewaytoken", "",{path:"/",expires:-1}); } }); } }); $("#firstname, #surname, #inputemailaddress, #inputrepeatemailaddress").on('keypress',function(e) { if(e.keyCode == 13) { debugger; var surname= $("#surname").val(); var emailaddress = $("#inputemailaddress").val(); var inputrepeatemailaddress = $("#inputrepeatemailaddress").val(); var isValid = true; if(emailaddress != ""){ if(!validateEmail(emailaddress)){ $("#validateemail").show(); $("#uservalidate").hide(); $("#emailsnotvalid").hide(); return false; } } if(emailaddress != inputrepeatemailaddress){ $("#emailsnotvalid").show(); $("#uservalidate").hide(); $("#validateemail").hide(); return false; } if(firstname == ""){ isValid = false; } if(surname == ""){ isValid = false; } if(emailaddress == ""){ isValid = false; } if(inputrepeatemailaddress == ""){ isValid = false; } if(!isValid){ $("#uservalidate").show(); return false; }else{ $("#uservalidate").hide(); } var messagerequest = {}; messagerequest.authentication = {}; messagerequest.authentication = {'gatewaytoken': vals }; messagerequest.firstname = $("#firstname").val(); messagerequest.surname = $("#surname").val(); messagerequest.emailaddress = $("#inputemailaddress").val(); messagerequest.usr = vals; messagerequest.email = email; $.ajax({ type : "POST", url : "/authentication/rest/login/usercreateotp", jsonpCallback : "authenticate_user", data: JSON.stringify(messagerequest), beforeSend : function() { $("#maincontent").show(); }, success : function(data) { debugger; var info = data; if(info.olddetails === "true" && info.userexist === "false"){ $("#loginfailedmessage").hide(); $("#loggedin").hide(); $("#loginbutton").hide(); $("#popup").hide(); $("#popupbutton").hide(); $("#userdetails").hide(); $("#userdetailsbutton").hide(); $("#emailsnotvalid").hide(); $("#uservalidate").hide(); $("#validateemail").hide(); $("#forgot").hide(); $("#userexists").hide(); $("#useronetimepin").show(); $("#otpbuttonvalidate").show(); $("#userinputotp").focus(); $("#textforOTP").html("We have sent a one time pin (OTP) to " + emailaddress + " please input this below..."); vals = info.usr; email = info.email; email_address = info.emailaddress; first_name = info.firstname; sur_name = info.surname; } else { if(info.olddetails === "true"){ hideProgress(); $("#loginfailedmessage").hide(); $("#loggedin").hide(); $("#loginbutton").hide(); $("#popup").hide(); $("#popupbutton").hide(); $("#userdetails").hide(); $("#userdetailsbutton").hide(); $("#emailsnotvalid").hide(); $("#uservalidate").hide(); $("#validateemail").hide(); $("#forgot").hide(); $("#onetimepin").hide(); $("#useronetimepin").hide(); $("#otpbuttonvalidate").hide(); $("#userexists").hide(); $("#passwordvalidation").show(); $("#password").focus(); $("#passwordvalidationbutton").show(); vals = info.usr; email = info.email; email_address = info.emailaddress; first_name = info.firstname; sur_name = info.surname; hideProgress(); } } }, complete : function() { hideProgress(); }, error : function(error) { if(error.responseText.includes("408")){ displayOverlay("Your session has timed out and you will be logged out automatically.
Please log in again in order to continue."); } if(error.responseJSON === "userexists"){ $("#userexists").show("slow", function(){}); }else{ $("#loginfailedmessage").show("slow", function(){}); } user.add("gatewaytoken", "",{path:"/",expires:-1}); } }); } }); $("#inputUsername, #inputPassword, #inputotp").on('keypress',function(e) { debugger; var opt = $("#inputotp").val(); if(e.keyCode == 13 && opt !== "") { $.ajax({ type : "POST", url : "/authentication/rest/login/otp", async:false, jsonpCallback : "authenticate_user", data: "otp=" + encodeURIComponent($("#inputotp").val()) + "&username=" + encodeURIComponent($("#inputUsername").val()) + "&password=" + encodeURIComponent($("#inputPassword").val()), success : function(data) { debugger; var info = data; hideProgress(); if(info.passwordexpired === "true"){ $("#loginblockedmessage").show(); $("#loggedin").hide(); $("#forgot").hide(); $("#loginblockedmessage").hide(); $("#loginfailedmessage").hide(); $("#loginbutton").hide(); $("#onetimepin").hide(); $("#loginotpmessage").hide(); $("#otpbutton").hide(); $("#expiredpasswordpopup").show(); $("#expiredpopupbutton").show(); $("#nextexpired").focus(); vals = info.token; email = info.email } if(info.olddetails === "true"){ $("#loginfailedmessage").hide(); $("#loginblockedmessage").hide(); $("#loggedin").hide(); $("#forgot").hide(); $("#loginbutton").hide(); $("#onetimepin").hide(); $("#loginotpmessage").hide(); $("#otpbutton").hide(); $("#popup").show(); $("#popupbutton").show(); $('#nextenter').focus(); vals = info.token; email = info.email; prepopfirstname=info.firstname; prepopsurname=info.surname; prepopemailaddress=info.email; prepopulate = info.populate; } else if(info.name != null){ user.add("gatewaytoken", data.token,{path:"/",expires:1}); user.add("gatewaytoken.account", data.account,{path:"/",expires:1}); user.add("gatewaytoken.name", data.name,{path:"/",expires:1}) window.location.href = "/redirect/" + window.location.search; } }, error : function(error) { hideProgress(); if(error.responseText.includes("408")){ displayOverlay("Your session has timed out and you will be logged out automatically.
Please log in again in order to continue."); } $("#loginfailedmessage").show("slow", function(){}); hideProgress(); user.add("gatewaytoken", "",{path:"/",expires:-1}); } }); }else if(e.keyCode == 13) { var inputusername = $("#inputUsername").val(); var inputpassword = $("#inputPassword").val(); if(inputusername === "" && inputpassword === ""){ $("#loginfailedmessage").show("slow", function(){}); return false; } if(inputusername === "" || inputpassword === ""){ $("#loginfailedmessage").show("slow", function(){}); return false; } //$("#maincontent").show(); $.ajax({ type : "POST", url : "/authentication/rest/login", jsonpCallback : "authenticate_user", data: "username=" + encodeURIComponent($("#inputUsername").val()) + "&password=" + encodeURIComponent($("#inputPassword").val()), beforeSend : function() { $("#maincontent").show(); }, success : function(data) { debugger; hideProgress(); var info = data; if(info.blocked === "true"){ $("#loginblockedmessage").show(); } if(info.passwordexpired === "true"){ $("#loginblockedmessage").show(); $("#loggedin").hide(); $("#forgot").hide(); $("#loginblockedmessage").hide(); $("#loginfailedmessage").hide(); $("#loginbutton").hide(); $("#onetimepin").hide(); $("#loginotpmessage").hide(); $("#otpbutton").hide(); $("#expiredpopup").show(); $("#expiredpopupbutton").show(); } if(info.olddetails === "true"){ $("#loggedin").hide(); $("#forgot").hide(); $("#loginblockedmessage").hide(); $("#loginfailedmessage").hide(); $("#loginbutton").hide(); $("#onetimepin").hide(); $("#loginotpmessage").hide(); $("#otpbutton").hide(); $("#popup").show(); $("#popupbutton").show(); } if(info.otp === "true" || info.registered === "true"){ $("#loginfailedmessage").hide(); $("#loginblockedmessage").hide(); $("#loginbutton").hide(); $("#onetimepin").show(); $("#otpbutton").show(); setTimeout(function(){ $('#loginotpmessage').toggle(); hideProgress(); }, 50); }else if(info.name != null){ user.add("gatewaytoken", data.token,{path:"/",expires:1}); user.add("gatewaytoken.account", data.account,{path:"/",expires:1}); user.add("gatewaytoken.name", data.name,{path:"/",expires:1}) window.location.href = "/redirect/" + window.location.search; } vals = info.token; email = info.email; hideProgress(); }, complete : function() { hideProgress(); }, error : function(error) { hideProgress(); if(error.responseText.includes("408")){ displayOverlay("Your session has timed out and you will be logged out automatically.
Please log in again in order to continue."); } $("#loginfailedmessage").show("slow", function(){}); user.add("gatewaytoken", "",{path:"/",expires:-1}); } }); hideProgress(); } }); /* Authenticate the user */ function authenticate(){ showSpinner(); $.ajax({ type : "POST", url : "/authentication/rest/login", jsonpCallback : "authenticate_user", data: "username=" + encodeURIComponent($("#inputUsername").val()) + "&password=" + encodeURIComponent($("#inputPassword").val()), beforeSend : function() { $("#maincontent").show(); }, success : function(data) { debugger; var info = data; if(info.blocked === "true"){ $("#loginblockedmessage").show(); } if(info.passwordexpired === "true"){ $("#loginblockedmessage").show(); $("#loggedin").hide(); $("#forgot").hide(); $("#loginblockedmessage").hide(); $("#loginfailedmessage").hide(); $("#loginbutton").hide(); $("#onetimepin").hide(); $("#loginotpmessage").hide(); $("#otpbutton").hide(); $("#expiredpopup").show(); $("#expiredpopupbutton").show(); } if(info.olddetails === "true"){ $("#loggedin").hide(); $("#forgot").hide(); $("#loginblockedmessage").hide(); $("#loginfailedmessage").hide(); $("#loginbutton").hide(); $("#onetimepin").hide(); $("#loginotpmessage").hide(); $("#otpbutton").hide(); $("#popup").show(); $("#popupbutton").show(); } if(info.otp === "true" || info.registered === "true"){ $("#loginfailedmessage").hide(); $("#loginblockedmessage").hide(); $("#loginbutton").hide(); $("#onetimepin").show(); $("#otpbutton").show(); setTimeout(function(){ $('#loginotpmessage').toggle(); }, 50); }else if(info.name != null){ user.add("gatewaytoken", data.token,{path:"/",expires:1}); user.add("gatewaytoken.account", data.account,{path:"/",expires:1}); user.add("gatewaytoken.name", data.name,{path:"/",expires:1}) window.location.href = "/redirect/" + window.location.search; } vals = info.token; email = info.email; }, complete : function() { hideProgress(); }, error : function(error) { hideProgress(); if(error.responseText.includes("408")){ displayOverlay("Your session has timed out and you will be logged out automatically.
Please log in again in order to continue."); } $("#loginfailedmessage").show("slow", function(){}); user.add("gatewaytoken", "",{path:"/",expires:-1}); } }); } function authenticateotp(){ $.ajax({ type : "POST", url : "/authentication/rest/login/otp", async:false, jsonpCallback : "authenticate_user", data: "otp=" + encodeURIComponent($("#inputotp").val()) + "&username=" + encodeURIComponent($("#inputUsername").val()) + "&password=" + encodeURIComponent($("#inputPassword").val()), success : function(data) { debugger; var info = data; if(info.passwordexpired === "true"){ $("#loginblockedmessage").show(); $("#loggedin").hide(); $("#forgot").hide(); $("#loginblockedmessage").hide(); $("#loginfailedmessage").hide(); $("#loginbutton").hide(); $("#onetimepin").hide(); $("#loginotpmessage").hide(); $("#otpbutton").hide(); $("#expiredpasswordpopup").show(); $("#expiredpopupbutton").show(); vals = info.token; email = info.email } if(info.olddetails === "true"){ $("#loginfailedmessage").hide(); $("#loginblockedmessage").hide(); $("#loggedin").hide(); $("#forgot").hide(); $("#loginbutton").hide(); $("#onetimepin").hide(); $("#loginotpmessage").hide(); $("#otpbutton").hide(); $("#popup").show(); $("#popupbutton").show(); $('#nextenter').focus(); vals = info.token; email = info.email; prepopfirstname=info.firstname; prepopsurname=info.surname; prepopemailaddress=info.email; prepopulate = info.populate; } else if(info.name != null){ user.add("gatewaytoken", data.token,{path:"/",expires:1}); user.add("gatewaytoken.account", data.account,{path:"/",expires:1}); user.add("gatewaytoken.name", data.name,{path:"/",expires:1}) window.location.href = "/redirect/" + window.location.search; } }, error : function(error) { if(error.responseText.includes("408")){ displayOverlay("Your session has timed out and you will be logged out automatically.
Please log in again in order to continue."); } $("#loginfailedmessage").show("slow", function(){}); user.add("gatewaytoken", "",{path:"/",expires:-1}); } }); } function floatFunction(){ $(".float-label").floatingFormLabel(); } function authenticatenext(){ debugger; $("#loggedin").hide(); $("#loginblockedmessage").hide(); $("#loginbutton").hide(); $("#forgot").hide(); $("#popup").hide(); $("#popupbutton").hide(); if(prepopulate === "true"){ $("#firstname").val(prepopfirstname); $("#surname").val(prepopsurname); $("#inputemailaddress").val(prepopemailaddress); $("#inputrepeatemailaddress").val(prepopemailaddress); } $("#firstname").show().focus(); $("#userdetails").show(); $("#userdetailsbutton").show(); document.getElementById('firstname').focus(); } function authenticateexpirednext(){ debugger; $("#loggedin").hide(); $("#loginblockedmessage").hide(); $("#loginbutton").hide(); $("#forgot").hide(); $("#expiredpasswordpopup").hide(); $("#expiredpopupbutton").hide(); $("#expiredpasswordvalidation").show(); $("#expiredpassword").focus(); $("#expiredpasswordvalidationbutton").show(); } function authenticateforgotpassword(){ $("#loggedin").hide(); $("#loginfailedmessage").hide(); $("#loginblockedmessage").hide(); $("#forgotpasswordfailedmessage").hide(); $("#loginbutton").hide(); $("#forgot").hide(); $("#forgotusername").show(); $("#forgotinputUsername").focus(); $("#passwordbuttonforgot").show(); } var alreadyexist = false; function authenticateemailforpassword(){ showSpinner(); if($("#forgotinputUsername").val() === ""){ return false; } if(!alreadyexist){ $.ajax({ type : "POST", url : "/authentication/rest/login/forgotpassword", jsonpCallback : "authenticate_user", data: "username=" + encodeURIComponent($("#forgotinputUsername").val()), beforeSend : function() { $("#maincontent").show(); }, success : function(data) { debugger; var info = data; if(info.otp === "true"){ $("#forgotusername").hide(); $("#loginfailedmessage").hide(); $("#loginblockedmessage").hide(); $("#passwordbuttonforgot").hide(); $("#forgotpasswordfailedmessage").hide(); $("#forgotpasswordotpbutton").show(); $("#forgotpasswordonetimepin").show(); $("#forgotpasswordinputotp").focus(); vals = info.usr; email = info.email; }else if(info.userold === "true"){ $("#forgotpasswordfailedmessage").show(); } }, complete : function() { hideProgress(); }, error : function(error) { if(error.responseText.includes("408")){ displayOverlay("Your session has timed out and you will be logged out automatically.
Please log in again in order to continue."); } $("#loginfailedmessage").show("slow", function(){}); user.add("gatewaytoken", "",{path:"/",expires:-1}); } }); }else{ $("#forgotpassword").focus(); } } /*$("#forgotinputUsername").on('keypress',function(e) { debugger; if(e.keyCode == 13){ if($("#forgotinputUsername").val() === ""){ $("#forgotemailaddress").show(); return false; } $.ajax({ type : "POST", url : "/authentication/rest/login/forgotpassword", jsonpCallback : "authenticate_user", data: "username=" + encodeURIComponent($("#forgotinputUsername").val()), beforeSend : function() { $("#maincontent").show(); }, success : function(data) { debugger; var info = data; if(info.otp === "true"){ $("#forgotusername").hide(); $("#loginfailedmessage").hide(); $("#loginblockedmessage").hide(); $("#passwordbuttonforgot").hide(); $("#forgotpasswordfailedmessage").hide(); $("#forgotemailaddress").hide(); $("#forgotpasswordotpbutton").show(); $("#forgotpasswordonetimepin").show(); $("#forgotpasswordinputotp").focus(); vals = info.usr; email = info.email; }else if(info.userold === "true"){ $("#forgotpasswordfailedmessage").show(); } }, complete : function() { hideProgress(); }, error : function(error) { if(error.responseText.includes("408")){ displayOverlay("Your session has timed out and you will be logged out automatically.
Please log in again in order to continue."); } $("#loginfailedmessage").show("slow", function(){}); user.add("gatewaytoken", "",{path:"/",expires:-1}); } }); } });*/ $("#forgotpasswordinputotp").on('keypress',function(e) { if(e.keyCode == 13){ alreadyexist = true; var messagerequest = {}; messagerequest.authentication = {}; messagerequest.authentication = {'gatewaytoken': vals }; messagerequest.otp = $("#forgotpasswordinputotp").val(); messagerequest.usr = vals; messagerequest.email = email; // "otp=" + encodeURIComponent($("#userinputotp").val()) + "&usr=" + encodeURIComponent(vals), if($("#forgotpasswordinputotp").val() == ""){ $("#forgotemailaddress").show(); hideProgress(); return false; } $.ajax({ type : "POST", url : "/authentication/rest/login/forgotpasswordvalidateotp", jsonpCallback : "authenticate_user", data:JSON.stringify(messagerequest), beforeSend : function() { $("#maincontent").show(); }, success : function(data) { debugger; var info = data; if(info.olddetails === "true"){ $("#loginfailedmessage").hide(); $("#loginblockedmessage").hide(); $("#forgotpasswordfailedmessage").hide(); $("#forgotpasswordotpbutton").hide(); $("#forgotpasswordonetimepin").hide(); $("#forgotpasswordvalidation").show(); $("#forgotemailaddress").hide(); $("#forgotpassword").focus(); $("#forgotpasswordvalidationbutton").show(); vals = info.usr; email = info.email; } }, complete : function() { hideProgress(); }, error : function(error) { if(error.responseText.includes("408")){ displayOverlay("Your session has timed out and you will be logged out automatically.
Please log in again in order to continue."); } $("#loginfailedmessage").show("slow", function(){}); user.add("gatewaytoken", "",{path:"/",expires:-1}); } }); } }); $("#forgotpassword, #forgotrepeatpassword").on('keypress',function(e) { if(e.keyCode==13){ var p = $("#forgotpassword").val(), errors = []; var repeatpassword = $("#forgotrepeatpassword").val(); var checkSpecial = /[*@!#%&()^~{}]+/.test(p), checkUpper = /[A-Z]+/.test(p), checkLower = /[a-z]+/.test(p); if (checkUpper && checkLower && checkSpecial) { }else{ errors.push("Password does not meet criteria."); } if(p != repeatpassword){ errors.push("Password does not match."); } if(p === ""){ errors.push("Password cannot be empty"); } if (errors.length > 0) { $("#invalidpassword").show(); $("#passwordinvalid").html(errors.join("\n")); return false; } var messagerequest = {}; messagerequest.authentication = {}; messagerequest.authentication = {'gatewaytoken': vals }; messagerequest.password = $("#forgotpassword").val(); messagerequest.email = email; $.ajax({ type : "POST", url : "/authentication/rest/login/forgotpasswordvalidate", jsonpCallback : "authenticate_user", data: JSON.stringify(messagerequest), beforeSend : function() { $("#maincontent").show(); }, success : function(data) { debugger; var info = data; if(info.success === "true"){ $("#loginfailedmessage").hide(); $("#loginblockedmessage").hide(); $("#forgotpasswordfailedmessage").hide(); $("#invalidpassword").hide(); $("#forgotpasswordvalidation").hide(); $("#forgotpasswordvalidationbutton").hide(); $("#forgotpasswordsuccess").show(); $("#successbutton").show(); $('#entersuccess').focus(); } }, complete : function() { hideProgress(); }, error : function(error) { if(error.responseText.includes("408")){ displayOverlay("Your session has timed out and you will be logged out automatically.
Please log in again in order to continue."); } $("#loginfailedmessage").show("slow", function(){}); user.add("gatewaytoken", "",{path:"/",expires:-1}); } }); } }); function authenticateforgotpassworduserotp(){ debugger; showSpinner(); var messagerequest = {}; messagerequest.authentication = {}; messagerequest.authentication = {'gatewaytoken': vals }; messagerequest.otp = $("#forgotpasswordinputotp").val(); messagerequest.usr = vals; messagerequest.email = email; // "otp=" + encodeURIComponent($("#userinputotp").val()) + "&usr=" + encodeURIComponent(vals), if($("#forgotpasswordinputotp").val() == ""){ $("#forgotemailaddress").show(); hideProgress(); return false; } $.ajax({ type : "POST", url : "/authentication/rest/login/forgotpasswordvalidateotp", jsonpCallback : "authenticate_user", data:JSON.stringify(messagerequest), beforeSend : function() { $("#maincontent").show(); }, success : function(data) { debugger; var info = data; if(info.olddetails === "true"){ $("#loginfailedmessage").hide(); $("#loginblockedmessage").hide(); $("#forgotpasswordfailedmessage").hide(); $("#forgotpasswordotpbutton").hide(); $("#forgotpasswordonetimepin").hide(); $("#forgotpasswordvalidation").show(); $("#forgotemailaddress").hide(); $("#forgotpassword").focus(); $("#forgotpasswordvalidationbutton").show(); vals = info.usr; email = info.email; } }, complete : function() { hideProgress(); }, error : function(error) { if(error.responseText.includes("408")){ displayOverlay("Your session has timed out and you will be logged out automatically.
Please log in again in order to continue."); } $("#loginfailedmessage").show("slow", function(){}); user.add("gatewaytoken", "",{path:"/",expires:-1}); } }); } function authenticateforgotpasswordvalidate(){ debugger; showSpinner(); var p = $("#forgotpassword").val(), errors = []; var repeatpassword = $("#forgotrepeatpassword").val(); var checkSpecial = /[*@!#%&()^~{}]+/.test(p), checkUpper = /[A-Z]+/.test(p), checkLower = /[a-z]+/.test(p); if (checkUpper && checkLower && checkSpecial) { }else{ errors.push("Password does not meet criteria."); } if(p != repeatpassword){ errors.push("Password does not match."); } if(p === ""){ errors.push("Password cannot be empty"); } if (errors.length > 0) { $("#invalidpassword").show(); $("#passwordinvalid").html(errors.join("\n")); return false; } var messagerequest = {}; messagerequest.authentication = {}; messagerequest.authentication = {'gatewaytoken': vals }; messagerequest.password = $("#forgotpassword").val(); messagerequest.email = email; $.ajax({ type : "POST", url : "/authentication/rest/login/forgotpasswordvalidate", jsonpCallback : "authenticate_user", data: JSON.stringify(messagerequest), beforeSend : function() { $("#maincontent").show(); }, success : function(data) { debugger; var info = data; if(info.success === "true"){ $("#loginfailedmessage").hide(); $("#loginblockedmessage").hide(); $("#forgotpasswordfailedmessage").hide(); $("#invalidpassword").hide(); $("#forgotpasswordvalidation").hide(); $("#forgotpasswordvalidationbutton").hide(); $("#forgotpasswordsuccess").show(); $("#successbutton").show(); $('#entersuccess').focus(); } }, complete : function() { hideProgress(); }, error : function(error) { if(error.responseText.includes("408")){ displayOverlay("Your session has timed out and you will be logged out automatically.
Please log in again in order to continue."); } $("#loginfailedmessage").show("slow", function(){}); user.add("gatewaytoken", "",{path:"/",expires:-1}); } }); } function displayOverlay(text) { $("
" + text + "
").css({ "position": "fixed", "top": "0px", "left": "0px", "width": "100%", "height": "100%", "background-color": "rgba(0,0,0,.5)", "z-index": "10000", "vertical-align": "middle", "text-align": "center", "color": "#fff", "font-size": "40px", "font-weight": "bold", "cursor": "wait" }).appendTo("body"); setTimeout(function(){ if(email === ""){ email = $("#username").val(); } logout(email); }, 5000); } function logout(username){ debugger; $.ajax({ type : "POST", url : "/authentication/rest/logout", async : false, jsonpCallback : "logout_user", data: "username=" + encodeURIComponent(username), success : function(data) { debugger; window.location.href = "/authentication/interface/?logout=true"; }, error : function(error) { $("#loginfailedmessage").show("slow", function(){}); user.add("gatewaytoken", "",{path:"/",expires:-1}); } }); } /* if we are being told to logout, then do it*/ if (page.urlParameters("logout") != null){ user.add("gatewaytoken", "",{path:"/",expires:"expired"}); user.add("gatewaytoken.account", "",{path:"/",expires:"expired"}); user.add("gatewaytoken.name", "",{path:"/",expires:"expired"}) }