var Unibase; (function (Unibase) { let Platform; (function (Platform) { let InviteUsers; (function (InviteUsers) { let Components; (function (Components) { class ResetPassword extends Platform.Core.BaseComponent { jsFiles() { return ["platform/inviteusers/managers/inviteusermanager.js", "platform/membership/managers/accountmanager.js", "platform/core/enums/rowstatus.js", "libs/passwordrequirement/passwordrequirement.js"]; } cssFiles() { return ["libs/passwordrequirement/passwordrequirement.css"]; } html(id, containerid) { let html = `
`; return html; } load(id, containerid, callback) { $(".pr-password").click(function () { var resetPswd = $(".pr-password"); resetPswd.passwordRequirements({ numCharacters: 8, useLowercase: true, useUppercase: true, useNumbers: true, useSpecial: true }); }); $("#PasswordHide").click(function () { var input = $('#NewPassword'); input.attr('type') == "password" ? input.attr('type', 'text') : input.attr('type', 'password'); $("#PasswordHide").toggleClass('fa-eye-slash fa-eye'); }); $("#confirmPasswordHide").click(function () { var input = $('#ConfirmPassword'); input.attr('type') == "password" ? input.attr('type', 'text') : input.attr('type', 'password'); $('#confirmPasswordHide').toggleClass('fa-eye-slash fa-eye'); }); $("#ConfirmPassword").val(''); $("#NewPassword").val(''); $("#frmRule_btncancel").click(function () { Unibase.Platform.Helpers.NavigationHelper.Instance().closePopUp(); }); var bizgazeid = $("#hf_" + $("#hfLayout_InstalledPageId").val() + "_BizgazeId").val(); $("#ConfirmPassword").on("focus", function () { $(".pwstrength_viewport_progress").addClass('hidden'); }); $("#NewPassword").on("keyup", function () { if ($(this).val().toString().length > 0) { $(".pwstrength_viewport_progress").removeClass('hidden'); } else { $(".pwstrength_viewport_progress").addClass('hidden'); } }); $("#NewPassword").keydown(function (key) { var password = $(this).val().toString(); var strength = 1; if (password.length >= 4) { strength += password.length; } if (password.toString().match(/([a-z].*[A-Z])|([A-Z].*[a-z])/)) { strength += 1; } if (password.toString().match(/([a-zA-Z])/) && password.toString().match(/([0-9])/)) { strength += 3; } if (password.toString().length < 4) { $(".changepwdpercent").css('width', '20%'); $(".password-verdict").html('Too Short'); } else if (strength >= 5 && strength < 7) { $(".changepwdpercent").css('width', '40%'); $(".password-verdict").html('Weak Password'); $(".changepwdpercent").css('background-color', 'red'); } else if (strength >= 8 && strength < 10) { $(".changepwdpercent").css('width', '60%'); $(".password-verdict").html('Good Password'); $(".changepwdpercent").css('background-color', 'Orange'); } else if (strength > 10) { $(".changepwdpercent").css('width', '80%'); $(".password-verdict").html('Strong Password'); $(".changepwdpercent").css('background-color', 'green'); } }); var username = bizgazeid; $("#hfUserName").val(username); $("#btnReset,.reset").click(function () { if ($("#NewPassword").val() == "") { MessageHelper.Instance().showError("Please Enter Password", 'resetPasswordDiv'); return false; } if ($("#ConfirmPassword").val() == "") { MessageHelper.Instance().showError("Please Enter Confirm Password", 'resetPasswordDiv'); return false; } if ($("#NewPassword").val().toString().length < 8 || $("#ConfirmPassword").val().toString().length < 8) { MessageHelper.Instance().showError("Password must be atleast 8 characters", 'resetPasswordDiv'); return false; } var val1 = $("#NewPassword").val(); var val2 = $("#ConfirmPassword").val(); if (val1 != val2) { MessageHelper.Instance().showError("New and confirm password does not match", 'resetPasswordDiv'); return false; } var password = $("#NewPassword").val().toString(); var decimal = /^(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[^a-zA-Z0-9])(?!.*\s).{8,30}$/; var checkpassword = password.match(decimal) ? true : false; if (checkpassword == false) { $(".pr-password").focus(); MessageHelper.Instance().showError("Please Match the Password in requested Format", "resetPasswordDiv"); return false; } var InstalledAppId = Unibase.Themes.Providers.DetailHelper.installedAppId; var unibaseid = Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + InstalledAppId + "_unibaseid").Value; var postData = { Password: val1.toString(), UserName: unibaseid.toString(), }; Unibase.Platform.InviteUsers.Managers.InviteUserManager.Instance().updatepassword(postData).then(function (response) { $('#' + containerid).modal('hide'); $('#' + containerid).remove(); $(".preloader-it").delay(200).fadeOut("slow"); if (response.status == Unibase.Data.Status.Success) { var user = Unibase.Platform.Membership.Infos.Identity.getCurrentUser(); Unibase.Platform.Membership.Managers.AccountManager.Instance().deleteUserDevices(user.unibaseId).then(function (res) { }); } MessageHelper.Instance().showSuccess(response.message, ''); }); }); } static Instance() { if (this.instance === undefined) { this.instance = new ResetPassword(); } return this.instance; } } Components.ResetPassword = ResetPassword; })(Components = InviteUsers.Components || (InviteUsers.Components = {})); })(InviteUsers = Platform.InviteUsers || (Platform.InviteUsers = {})); })(Platform = Unibase.Platform || (Unibase.Platform = {})); })(Unibase || (Unibase = {}));