// this is copied from stp-login.js and is adjusted to support reset password logic $(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 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 : true, value : $("link[rel=userEmail]").attr( "value" ) }) .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" ); // } // }; // fsproEmail.option( "onValueChanged", function( e ) { // emailUpdated( e.value ); // }); let fsproNewPassword = $("#fsproNewPassword").dxTextBox({ mode : "password", name : "fsproNewPassword", placeholder : "New Password", buttons : [ { name : "password", location : "after", options: { icon: 'eyeopen', type: 'normal', stylingMode : 'text', onClick : function ( e ) { fsproNewPassword.option('mode', fsproNewPassword.option('mode') === 'text' ? 'password' : 'text'); } } }] }) .dxTextBox( "instance" ); $("#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 } ); let fsproConfirmPassword = $("#fsproConfirmPassword").dxTextBox({ mode : "password", name : "fsproConfirmPassword", placeholder : "Confirm New Password", buttons : [ { name : "password", location : "after", options: { icon: 'eyeopen', type: 'normal', stylingMode : 'text', onClick : function ( e ) { fsproConfirmPassword.option('mode', fsproConfirmPassword.option('mode') === 'text' ? 'password' : 'text'); } } }] }) .dxTextBox( "instance" ); $("#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" }, { type: "stringLength", message: "Passwords must be at least 8 characaters", min : 8 } ], validationGroup : validationGroup } ); // let fsproRememberMe = $("#fsproRememberMe").dxCheckBox( { // name : "fsproRememberMe", // text : "Remember my email", // value : rememberedEmail != "" // }).dxCheckBox("instance"); let resetPasswordButton = $("#resetPasswordButton").dxButton({ text : "Reset Password", type : "default", validationGroup : validationGroup, onClick : function( e ) { let result = e.validationGroup.validate(); if( ! result.isValid ) { return; } let saveData = {}; saveData.fsproNewPassword = fsproNewPassword.option( "value" ); saveData.fsproConfirmPassword = fsproConfirmPassword.option( "value" ); saveData.resetLink = $("link[rel=resetLink").attr( "value" ); console.log( "saveData", saveData ); let theLoginButton = e.component; theLoginButton.option( "disabled", true ); // ssoButtons.forEach( button => button.option( "disabled", true ) ); $("#fsproLoginStatus").html( "Resetting password..." ); $.ajax({ type: "post", url: "actions/passwordReset.cfm", cache : false, data: saveData }).done(function(data) { if( data.success ) { $("
").dxToast( { message : "Your password has been reset. You will now be able to login using the new password.", type : "success", hideOnOutsideClick : true, displayTime : 2000, onHidden : function( e ) { window.location.href = data.go; } }).appendTo( $("body" )).dxToast( "show" ); } else { $("
").dxToast( { message : data.message, type : "warning", hideOnOutsideClick : true, displayTime : 2000, onHidden : function( e ) { window.location.href = window.location.href; } }).appendTo( $("body" )).dxToast( "show" ); } }).fail(function(data) { $("
").dxToast( { message : "Password reset is not available at this time, please try again later!", type : "error", hideOnOutsideClick : true, displayTime : 3000, onHidden : function( e ) { window.location.href = window.location.href; } }).appendTo( $("body" )).dxToast( "show" ); }); } }) .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) // }); // } })