$(function() { let cookiePath = $("link[rel=cookie-path]").attr( "value" ); let cookieDomain = $("link[rel=cookie-domain]").attr( "value" ); let portalName = $("link[rel=portalName]").attr( "value" ); let rememberMeCookieName = portalName + "rememberMe"; let changePassword = false; let mfaEnabled = false; let getCookie = function( cookieName ){ let name = cookieName + "="; let decodedCookie = decodeURIComponent(document.cookie); let ca = decodedCookie.split(';'); for(let i = 0; i ").dxButton( { text : "Sign in with " + p.attr( "title" ), // icon : "key", type : "normal", width : "100%", onClick : function( e ) { window.location.href = p.attr( "href" ); } }) button.appendTo( providerButtonSection ).addClass( "sso-button" ); ssoButtons.push( button.dxButton( "instance" ) ); }) } fsproEmail = $("#fsproEmail").dxTextBox({ mode : "email", name : "fsproEmail", placeholder : "Email", disabled_onKeyUp : function( e ) { if( e.event.keyCode == 13 ) { let ssoLoginPageURL = getSSORedirectURL(); if( ssoLoginPageURL ) { window.location.href = ssoLoginPageURL; } } } }) .dxValidator( { elementAttr : { id : "fsproEmailValidator" }, validationGroup : validationGroup, validationRules : [ { type: "required", message: "Email is required" }, { type: "custom", validationCallback : function( e ) { let aValues = e.value.split( "/" ); return validateEmailAddress( aValues[0] ); }, message: "Email is invalid" } ] }) .dxTextBox("instance"); let fsproEmailValidator = $("#fsproEmailValidator").dxValidator( "instance" ); let fsproPassword = $("#fsproPassword").dxTextBox({ mode : "password", name : "fsproPassword", placeholder : "Password", buttons: [{ name: 'password', location: 'after', options: { icon: 'eyeopen', type: 'normal', stylingMode : 'text', onClick() { fsproPassword.option('mode', fsproPassword.option('mode') === 'text' ? 'password' : 'text'); }, }, }], onKeyUp : function( e ) { $("#fsproLoginStatus").html( "" ); if( e.event.keyCode == 13 ) { DevExpress.events.trigger( document.getElementById( "fsproLoginButton" ), "click" ); } } }) .dxValidator( { validationRules : [ { type : "required", message : "Password is required" } ], validationGroup : validationGroup }) .dxTextBox("instance"); let ssoRedirect = false; let emailUpdated = function( emailValue ) { let bDisabled = false; let bDisabledOriginal = fsproPassword.option( "disabled" ); let ssoRedirectURL = getSSORedirectURL( emailValue ); if( ssoRedirectURL ) { ssoRedirect = true; bDisabled = true } else { ssoRedirect = false; bDisabled = false; } fsproPassword.option( "disabled", bDisabled ); if( ! bDisabled && bDisabledOriginal ) { fsproPassword.focus(); } if( ssoRedirect ) { $("#ifmp").css( "visibility", "hidden" ); } else { $("#ifmp").css( "visibility", "visible" ); } /* let bDisabled = true; let bDisabledOriginal = fsproPassword.option( "disabled" ); if( emailValue != "" ) { let emailAddresses = emailValue.split( "/" ); let emailAddress = emailAddresses[0]; if( emailAddresses.length == 1 ) { let emailParts = emailAddress.split( "@" ); if( emailParts.length > 1 ) { emailParts.shift(); } emailAddress = "*@" + emailParts[0]; } let noRedirectEmail = $("link[rel=ssoRedirectNo]").attr( "value" ); if( noRedirectEmail.indexOf( emailAddress.toLowerCase() ) != -1) { bDisabled = false; } } ssoRedirect = bDisabled; fsproPassword.option( "disabled", bDisabled ); if( ! bDisabled && bDisabledOriginal ) { fsproPassword.focus(); } if( ssoRedirect ) { $("#ifmp").css( "visibility", "hidden" ); } else { $("#ifmp").css( "visibility", "visible" ); } */ }; fsproEmail.option( "onValueChanged", function( e ) { emailUpdated( e.value ); }); /* obsolete $("#showPassword").click( function() { let element = $(this); let passwordMode = fsproPassword.option( "mode" ); if( passwordMode == "password" ) { element.html( "hide" ); fsproPassword.option( "mode", "text" ); } else { element.html( "show" ); fsproPassword.option( "mode", "password" ); } }) */ /* if( $("link[rel=ssoRedirect]").attr( "href" ) != "" ) { fsproPassword.option( "disabled", true ); ssoRedirect = true; fsproEmail.option( "onValueChanged", function( e ) { emailUpdated( e.value ); }); if( rememberedEmail ) { emailUpdated( rememberedEmail ) } } */ let fsproNewPassword = $("#fsproNewPassword").dxTextBox({ mode : "password", name : "fsproNewPassword", placeholder : "New Password" }) .dxTextBox( "instance" ); let fsproConfirmPassword = $("#fsproConfirmPassword").dxTextBox({ mode : "password", name : "fsproConfirmPassword", placeholder : "Confirm New Password" }) .dxTextBox( "instance" ); let fsproMFACode = $("#fsproMFACode").dxTextBox({ name : "fsproMFACode", placeholder : "Security Code" }).dxTextBox( "instance" ); let fsproRememberMe = $("#fsproRememberMe").dxCheckBox( { name : "fsproRememberMe", text : "Remember my email", value : rememberedEmail != "" }).dxCheckBox("instance"); let fsproLoginButton = $("#fsproLoginButton").dxButton({ text : "Login", type : "default", validationGroup : validationGroup, onClick : function( e ) { let result = e.validationGroup.validate(); if( ! result.isValid ) { return; } let saveData = {}; saveData.fsproEmail = fsproEmail.option( "value" ); saveData.fsproPassword = fsproPassword.option( "value" ); if( changePassword ) { saveData.fsproNewPassword = fsproNewPassword.option( "value" ); saveData.fsproConfirmPassword = fsproConfirmPassword.option( "value" ); } if( mfaEnabled ) { saveData.fsproMFACode = fsproMFACode.option( "value" ); } if( fsproRememberMe.option( "value" )) { // set the cookie setCookie( rememberMeCookieName, saveData.fsproEmail, 60 ); } else { // delete the cookie deleteCookie( rememberMeCookieName ); } let ssoRedirectURL = getSSORedirectURL( saveData.fsproEmail ); if( ssoRedirectURL ) { window.location.href = ssoRedirectURL; return; } /* if( ssoRedirect ) { window.location.href = $("link[rel=ssoRedirect]").attr( "href" ); return; } */ let theLoginButton = e.component; theLoginButton.option( "disabled", true ); ssoButtons.forEach( button => button.option( "disabled", true ) ); $("#fsproLoginStatus").html( "Signing in..." ); $.ajax({ type: "post", url: "actions/login.cfm", cache : false, data: saveData }).done(function(data) { if( data.success ) { window.location.href = data.go; } else { $("#fsproLoginStatus").html( data.message ); theLoginButton.option( "disabled", false ); ssoButtons.forEach( button => button.option( "disabled", false ) ); if( data.changePassword ) { /* add validators to new password and confirm password */ $("#fsproNewPassword").dxValidator ( { validationRules : [ { type: "required", message: "New Password is required" }, { type: "stringLength", message: "Passwords must be at least 8 characaters", min : 8 }, { type : "pattern", pattern : "^(?=.*[a-z])(?=.*[A-Z])(?=.*\\d).*$", message : "Passwords must contain at least 1 uppercase letter, 1 lowercase letter and 1 numeric character" } ], validationGroup : validationGroup } ); $("#fsproConfirmPassword").dxValidator ( { validationRules : [ { type: "compare", comparisonTarget: function() { return fsproNewPassword.option( "value" ); }, message: "'New' and 'Confirm' do not match." }, { type: "required", message: "Confirm Password is required" } ], validationGroup : validationGroup } ); $(".login-container").removeClass( "no-password-change" ); $(".login-container").addClass( "password-change" ); fsproNewPassword.focus(); changePassword = true; } if( data.mfaEnabled ) { $("#fsproMFACode").dxValidator ( { validationRules : [ { type: "required", message: "New Password is required" } ], validationGroup : validationGroup } ); $(".login-container") .removeClass( "mfa-disabled" ) .addClass( "mfa-enabled" ); mfaEnabled = true; fsproMFACode.focus(); } } }).fail(function(data) { DevExpress.ui.notify("login not available at this time, please try again later!", "error", 2000) }); } }) .css( { "font-size" : "14px" } ) .dxButton("instance"); if( rememberedEmail && rememberedEmail != "" ) { fsproEmail.option( "value", rememberedEmail ); } if( rememberedEmail != "" ) { fsproPassword.focus(); } else { fsproEmail.focus(); } window._resetPassword = function( e ) { fsproEmailValidator.validate(); if( ! fsproEmail.option( "isValid" ) ) { fsproEmail.focus(); return; } if( ! confirm( "An email will be sent with instructions on how to reset your password. Continue?" )) { return; } let saveData = {}; saveData.fsproEmail = fsproEmail.option( "value" ); $.ajax({ type: "post", url: "actions/passwordReset.cfm", data: saveData }).done(function(data) { DevExpress.ui.notify("a password reminder email has been sent to " + saveData.fsproEmail, "info", 2000) }).fail(function(data) { DevExpress.ui.notify("a password reminder email cannot be sent at this time, please try again later!", "error", 2000) }); } })