123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780 |
- function initLogin() {
- // alert('as')
- // Command: toastr["success"]("Logged in successfully")
- // Command: toastr["success"]("My name is Inigo Montoya. You killed my father. Prepare to die!")
-
- // toasterOpts();
- let reg_name, reg_email, reg_number, reg_pwd, reg_otp_email;
- let loginForm = $("#login_form");
- let registerForm = $("#register_form");
-
- $("#register_form .otp-input-group input.press").on("paste", function (p) {
- var data = p.originalEvent.clipboardData.getData("text");
- var dataLength = data.length;
-
- for (var i = 0; i < dataLength; i++) {
- var input = $(
- '#register_form .otp-input-group input[tabindex="' + (i + 1) + '"]'
- );
- input.val(data.charAt(i));
- if (input.val().length >= input.attr("maxlength")) {
- var nextInput = $(
- '#register_form .otp-input-group input[tabindex="' + (i + 2) + '"]'
- );
- if (nextInput) {
- nextInput.focus();
- }
- }
- }
- p.preventDefault();
- });
-
- $('#register_form .otp-input-group input[type="text"]').on(
- "keyup",
- function (e) {
- if ($(this).val().length >= $(this).attr("maxlength")) {
- if (e.keyCode !== 9 && e.keyCode !== 16) {
- var tabIndex = parseInt($(this).attr("tabindex")) + 1;
- $(
- '#register_form .otp-input-group input[tabindex="' +
- $(this).attr("tabindex") +
- '"]'
- ).val($(this).val());
- $(
- '#register_form .otp-input-group input[tabindex="' + tabIndex + '"]'
- ).focus();
- }
- } else {
- if (e.keyCode === 8) {
- var tabIndex = parseInt($(this).attr("tabindex")) - 1;
- $(
- '#register_form .otp-input-group input[tabindex="' + tabIndex + '"]'
- ).focus();
- }
- }
- }
- );
-
- loginForm.find("#User_Email,#User_password").keypress(function (e) {
- if (e.which == 13) $("#Login_btn").click();
- });
-
- $("#Login_btn").click(function () {
- $('.error_msg').hide();
- // loginForm.find(".loader-btn").show();
- let userEmail = loginForm.find("#User_Email").val();
- let userPassword = loginForm.find("#User_password").val();
- let emailInput = loginForm.find(".email-login-inputgroup");
- let passwordInput = loginForm.find(".password-login-inputgroup");
- if (userEmail == "") {
- emailInput.find("#User_Email").addClass("is-invalid");
- emailInput.find(".form-floating").addClass("is-invalid");
- emailInput.find(".invalid-feedback").text("Please enter your email");
- loginForm.find(".loader-btn").hide();
- $(this).show();
- }
- if (userPassword == "") {
- passwordInput.find("#User_password").addClass("is-invalid");
- passwordInput.find(".form-floating").addClass("is-invalid");
- loginForm.find(".loader-btn").hide();
- $(this).show();
- } else {
- emailInput.find("#User_Email").removeClass("is-invalid");
- emailInput.find(".form-floating").removeClass("is-invalid");
- passwordInput.find("#User_password").removeClass("is-invalid");
- passwordInput.find(".form-floating").removeClass("is-invalid");
- if (validateEmail(userEmail)) {
- let port = SERVERNAME
- // let port = "http://localhost:3088";
- let url = `${port}/account/getuserbyphoneormail/${userEmail}/${userEmail}`;
- getDataStatAxios(url, userEmail);
- } else {
- loginForm.find(".loader-btn").hide();
- $(this).show();
- emailInput.find("#User_Email").addClass("is-invalid");
- emailInput.find(".form-floating").addClass("is-invalid");
- emailInput.find(".invalid-feedback").text("Please enter a valid email");
- }
- }
- });
- async function getDataStatAxios(url, userEmail) {
- const config = {
- url,
- method: "get",
- };
- let response = await axios(config);
- if (response.data.result == null) {
- $('.error_msg').show();
- $('.error_msg .error_msg_res').html(`User doesn't exists with the email, <a href="#" class="alert-link register_sectionbtn" id="register_sectionbtn">Sign Up </a>`);
- $(".register_sectionbtn").click(function(){
-
-
- $(".login_section").css("display","none");
- $(".register_section").css("display","block");
- $(".login_section").find("#User_Email").removeClass("is-invalid");
- $(".login_section").find(".form-floating").removeClass("is-invalid");
- $(".login_section").find("#User_password").removeClass("is-invalid");
- $(".login_section").find(".form-floating").removeClass("is-invalid");
- $('.error_msg').hide();
- });
- // toasterOpts();
-
- // Command: toastr["error"]("Please enter Valid email / password");
- } else {
- let userEmail = $("#User_Email").val();
- let userPassword = $("#User_password").val();
- const loginPayload = {
- username: userEmail,
- Password: userPassword,
- UnibaseId: "",
- RememberMe: false,
- };
- $("#Login_btn").hide();
- $(".loader-btn").show();
- const res = await postAPIService(
- `bizgaze/crm/webapi/crmuserlogin`,
- loginPayload
- );
- debugger;
- console.log(res);
- $(".loader-btn").hide();
- $("#Login_btn").show();
- if (res.data.message == "200") {
- debugger;
- // Command: toastr["success"]("Logged in successfully")
- // toasterOpts();
- COOKIE_HELPER_ACTIONS.setCookie({
- token: res.data.result.sessionId,
- userid: res.data.result.userId,
- ...res.data.result
- });
- // setInitLoginLocal();
- window.localStorage.setItem("Useremail", userEmail);
- //window.localStorage.setItem("Userpassword", userPassword);
- window.localStorage.setItem("Isloggedintoaster", true);
- window.localStorage.setItem("Isloggedin", true);
-
- const isCartAdded = localStorage.getItem(CART_ADD);
- if(isCartAdded){
- localStorage.removeItem(CART_ADD);
- window.location.href = `/selectdelivery.html`;
- return;
- }
-
- window.location.href = `./index.html`;
- } else {
- $('.error_msg').show();
- $('.error_msg .error_msg_res').html(res.data.message + ' <a class="validate_mail text-danger"><b>Validate Email</b></a>');
- // toasterOpts();
- // Command: toastr["error"]()
- /*Email validation*/
- $('.validate_mail').click(function(){
- $(".login_section").hide();
- $(".email-validate-div").show();
- $('.error_msg').hide();
- })
- }
- }
- }
-
- // this function will be triggered on new user registration
- async function userRegistration() {
- reg_form = $("#register_form");
- // reg_name = $("#User_Name").val();
- reg_email = reg_form.find("#User_Email").val();
- // reg_otp_email = $("#User_otp_Email").val();
- // reg_number = $("#user_number").val();
- reg_pwd = reg_form.find("#User_password").val();
- let userName = reg_email.split("@");
- let otpRes = null;
- const userRegistratioNPayload = {
- organizationtypeid: "2",
- organizationid: "0",
- contactid: "0",
- userid: "0",
- username: "0",
- users_phonenumber: "0",
- password: reg_pwd,
- users_emailaddress: "0",
- emailaddress: reg_email,
- contactname: userName[0],
- phonenumber: "0",
- branchid: "0",
- tenantname: "Anwi Systems",
- rolename: "Customer Admin",
- currencyid: "0",
- customerformuniqueid: "Bizgaze_Platform_Crm_RegisterCRMUser",
- };
- debugger;
- $('#register_btn').hide()
- $(".loader-btn").show();
- debugger;
- const res = await postAPIService(
- `bizgaze/crm/webapi/registercrmuser`,
- userRegistratioNPayload
- );
- console.log(res, "register");
- $(".loader-btn").hide();
- $('#register_btn').show()
- if (res.data.code == "404" ) {
- // toasterOpts();
- // Command: toastr["error"](res.data.message)
- $('.error_msg').show();
- $('.error_msg .error_msg_res').html(res.data.message);
- return;
- }
- else {
- $("#register_form .email-password-group").hide();
- $("#register_form .register_otp.otp-input-group").show();
- }
-
- $("#proceed").click(async function () {
- let userEnterOtp = "";
- let userEmail = registerForm.find("#User_Email").val();
- $(".otp-input-group input").each(function () {
- let presVal = $(this).val();
- userEnterOtp += presVal;
- });
- console.log(userEnterOtp);
- debugger;
- const userotppayload = {
- email: userEmail,
- otpid: res.data.result.OtpId,
- userotp: userEnterOtp,
- };
- $(".loader-btn").show();
- $('#proceed').hide()
- otpRes = await postAPIService(
- `bizgaze/crm/webapi/ValidateOtp`,
- userotppayload
- );
- $(".loader-btn").hide();
- $('#proceed').show()
- debugger;
- console.log(otpRes, "otp");
- const verifyotpStatus = otpRes.data.result;
- if (verifyotpStatus == "Otp verified successfully") {
- const loginPayload = {
- username: reg_email,
- Password: reg_pwd,
- UnibaseId: "",
- RememberMe: false,
- };
- const res = await postAPIService(
- `bizgaze/crm/webapi/crmuserlogin`,
- loginPayload
- );
- if (res.data.message == "200") {
- debugger;
- // Command: toastr["success"]("Logged in successfully")
- // toasterOpts();
- COOKIE_HELPER_ACTIONS.setCookie({
- token: res.data.result.sessionId,
- userid: res.data.result.userId,
- ...res.data.result
- });
- // setInitLoginLocal();
- window.localStorage.setItem("Useremail", userEmail);
- //window.localStorage.setItem("Userpassword", userPassword);
- window.localStorage.setItem("isaccountCreated", true);
- const isCartAdded = localStorage.getItem(CART_ADD);
- if(isCartAdded){
- localStorage.removeItem(CART_ADD);
- window.location.href = `/selectdelivery.html`;
- return;
- }
- window.location.href = `./index.html`;
- } else {
- // toasterOpts();
- // Command: toastr["error"](res.data.message)
- $('.error_msg').show();
- $('.error_msg .error_msg_res').html(res.data.message);
- }
- } else {
- // toasterOpts();
- // Command: toastr["error"]("Please enter Valid OTP");
- $('.error_msg').show();
- $('.error_msg .error_msg_res').html("Please enter Valid OTP");
- }
- });
- }
-
- // to validate password on keyup in password input field
- function passwordValidate(pswd) {
- if (pswd.length < 8) {
- $("#chck_length").removeClass("pswd_valid").addClass("pswd_invalid");
- } else {
- $("#chck_length").removeClass("pswd_invalid").addClass("pswd_valid");
- }
- // validate uppercase letter
- if (pswd.match(/[A-Z]/)) {
- $("#chck_capital").removeClass("pswd_invalid").addClass("pswd_valid");
- } else {
- $("#chck_capital").removeClass("pswd_valid").addClass("pswd_invalid");
- }
- //validate special letter
- if (pswd.match(/[!@#$%^&*]/)) {
- $("#chck_special").removeClass("pswd_invalid").addClass("pswd_valid");
- } else {
- $("#chck_special").removeClass("pswd_valid").addClass("pswd_invalid");
- }
- let pswdVal = $("#register_form #User_password").val();
- let pattern = /^(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[^a-zA-Z0-9]).{8,}$/;
- if (pswdVal.match(pattern)) {
- $(".pswd_info").hide();
- } else {
- $(".pswd_info").show();
- }
- //validate number
- if (pswd.match(/\d/)) {
- $("#chck_number").removeClass("pswd_invalid").addClass("pswd_valid");
- } else {
- $("#chck_number").removeClass("pswd_valid").addClass("pswd_invalid");
- }
- }
-
- //you have to use keyup, because keydown will not catch the currently entered value
- $("#register_form #User_password")
- .keyup(function () {
- // set password variable
- var pswd = $(this).val();
- passwordValidate(pswd);
- })
- .focus(function () {
- let pswdVal = $("#register_form #User_password").val();
- let pattern = /^(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[^a-zA-Z0-9]).{11,}$/;
- if (pswdVal.match(pattern)) {
- $(".pswd_info").hide();
- } else {
- $(".pswd_info").show();
- }
- })
- .blur(function () {
- $(".pswd_info").hide();
- });
-
- // function to validate user entered email
- function validateEmail(userEmail) {
- var pattern = /^([\w-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/;
- // return $.trim(userEmail).test(pattern) ? true : false;
- return pattern.test(userEmail) ? true : false;
- }
-
- // function to validate user entered password
- function validatepassword(userPassword) {
- var pattern = /^(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[^a-zA-Z0-9])(?!.*\s).{8,15}$/;
- // return $.trim(userPassword).test(pattern) ? true : false;
- return pattern.test(userPassword) ? true : false;
- }
-
- registerForm.find("#User_Email,#User_password").keypress(function (e) {
- if (e.which == 13) $("#register_btn").click();
- });
-
- // this will be triggered on clicking continue in signup form
- $("#register_btn").click(function () {
- $('.error_msg').hide();
- registerForm.find(".loader-btn").show();
- $(this).hide();
- let userEmail = registerForm.find("#User_Email").val();
- let userPassword = registerForm.find("#User_password").val();
- let emailInput = registerForm.find(".email-login-inputgroup");
- let passwordInput = registerForm.find(".password-login-inputgroup");
- if (userEmail == "") {
- emailInput.find("#User_Email").addClass("is-invalid");
- emailInput.find(".form-floating").addClass("is-invalid");
- emailInput.find(".invalid-feedback").text("Please enter your email");
- registerForm.find(".loader-btn").hide();
- $(this).show();
- }
- if (userPassword == "") {
- passwordInput.find("#User_password").addClass("is-invalid");
- passwordInput.find(".form-floating").addClass("is-invalid");
- registerForm.find(".loader-btn").hide();
- $(this).show();
- } else {
- emailInput.find("#User_Email").removeClass("is-invalid");
- emailInput.find(".form-floating").removeClass("is-invalid");
- passwordInput.find("#User_password").removeClass("is-invalid");
- passwordInput.find(".form-floating").removeClass("is-invalid");
- let Email_valid = validateEmail(userEmail);
- let Pwd_valid = validatepassword(userPassword);
- if (Email_valid === true && Pwd_valid === true) {
- userRegistration();
- $("#register_form .otp-input-group .otp-sent-email").text(userEmail);
- } else if(Email_valid === false) {
- emailInput.find("#User_Email").addClass("is-invalid");
- emailInput.find(".form-floating").addClass("is-invalid");
- emailInput.find(".invalid-feedback").text("Please enter a valid email");
- registerForm.find(".loader-btn").hide();
- $(this).show();
- }else if(Pwd_valid === false){
- passwordInput.find("#User_password").addClass("is-invalid");
- passwordInput.find(".form-floating").addClass("is-invalid");
- passwordInput.find(".invalid-feedback").text("Please check the password!");
- registerForm.find(".loader-btn").hide();
- $(this).show();
- }
- }
- });
- $(".pswd_eye").click(function(){
- let eyeClass = $(this).find('svg').hasClass("fa-eye-slash");
- if(eyeClass == true){
- $(this).find('svg').removeClass("fa-eye-slash");
- $(this).find('svg').addClass("fa-eye");
- $(this).siblings('input').attr('type','password')
- }else{
- $(this).find('svg').removeClass("fa-eye");
- $(this).find('svg').addClass("fa-eye-slash");
- $(this).siblings('input').attr('type','text')
- }
- })
-
- $("#forgotPassword").click(function () {
- $(".login-email-password-div").hide();
- $(".login-forgot-password-div").show();
- });
- $("#forgot_Password_Back").click(function () {
- $(".login-forgot-password-div").hide();
- $(".login-email-password-div").show();
- });
- $("#forgot_password_submit").click(async function () {
- let forgot_email = $("#forgot_User_Email").val();
- if(forgot_email == ''){
- $('#forgot_User_Email').addClass('is-invalid')
- $('#forgot_User_Email').after(`<div class="invalid-feedback">Please enter Valid email</div>`);
- return
- }
- else{
- debugger;
- let port = SERVERNAME
- // let port = "http://localhost:3088";
- let url = `${port}/account/getuserbyphoneormail/${forgot_email}/${forgot_email}`;
- const config = {
- url,
- method: "get",
- };
- $(".loader-btn").show();
- $('#forgot_password_submit').hide()
- let response = await axios(config);
- debugger;
- console.log(response);
- $(".loader-btn").hide();
- $('#forgot_password_submit').show()
- if (response.data.result != null) {
- debugger;
- console.log(response.data);
- const forgotpassPayload = {
- firstname: "",
- lastname: "",
- contactnumber: "",
- email: "",
- tenantname: "",
- contactoremail: response.data.result.email,
- IsSignup: false,
- IsRegisterUser: false,
- IsForgotPswd: true,
- UnibaseId: response.data.result.userName,
- OtpId: 0,
- UserOtp: "",
- };
- $('#forgot_password_submit').hide()
- $(".loader-btn").show();
- const forgetpassRes = await postAPIService(
- `account/sendotp`,
- forgotpassPayload
- );
- $(".loader-btn").hide();
- console.log(forgetpassRes);
- $(".email-validation").hide();
- $('.user_email').html(forgot_email)
- $(".otp-validation .otp-input-group").show();
- $(".otp-validation .otp-input-group").on("paste", function (p) {
- let data = p.originalEvent.clipboardData.getData("text");
- let dataLength = data.length;
- for (let i = 0; i < dataLength; i++) {
- let input = $(
- '.otp-validation .otp-input-group input[tabindex="' + (i + 1) + '"]'
- );
- input.val(data.charAt(i));
- if (input.val().length >= input.attr("maxlength")) {
- let nextInput = $(
- '.otp-validation .otp-input-group input[tabindex="' +
- (i + 2) +
- '"]'
- );
- if (nextInput) {
- nextInput.focus();
- }
- }
- }
- p.preventDefault();
- });
-
- $('.otp-validation .otp-input-group input[type="text"]').on(
- "keyup",
- function (e) {
- if ($(this).val().length >= $(this).attr("maxlength")) {
- if (e.keyCode !== 9 && e.keyCode !== 16) {
- let tabIndex = parseInt($(this).attr("tabindex")) + 1;
- $(
- '.otp-validation .otp-input-group input[tabindex="' +
- $(this).attr("tabindex") +
- '"]'
- ).val($(this).val());
- $(
- '.otp-validation .otp-input-group input[tabindex="' +
- tabIndex +
- '"]'
- ).focus();
- }
- } else {
- if (e.keyCode === 8) {
- let tabIndex = parseInt($(this).attr("tabindex")) - 1;
- $(
- '.otp-validation .otp-input-group input[tabindex="' +
- tabIndex +
- '"]'
- ).focus();
- }
- }
- }
- );
- $("#Forgot_pass_proceed").click(async function () {
- debugger;
- let userotp='';
- $(".otp-validation .otp-input-group input").each(function () {
- let presVal = $(this).val();
- userotp += presVal;
- });
- console.log(userotp);
- const validateForgotpass = {
- email: forgot_email,
- otpid: forgetpassRes.data,
- userotp: userotp,
- };
- $('#Forgot_pass_proceed').hide()
- $(".loader-btn").show();
- const forgetpassResotp = await postAPIService(
- `hyperfusion/validateotp`,
- validateForgotpass
- );
- $(".loader-btn").hide();
- $('#Forgot_pass_proceed').show()
- console.log(forgetpassResotp);
- const Resotp = forgetpassResotp.data.result;
- if (Resotp == "Otp verified successfully") {
- $(".login-forgot-password-details-div").show();
- $(".otp-validation .otp-input-group").hide();
- } else {
- // toasterOpts()
- // Command: toastr["error"]("Please enter Valid OTP");
- $('.error_msg').show();
- $('.error_msg .error_msg_res').html("Please enter Valid OTP");
- }
- });
- $("#forgot_password_details_submit").click(async function () {
- debugger;
- let pswdone =$("#forgot-password-input-one").val();
- let pswdtwo =$("#forgot-password-input-two").val();
- if(pswdone == pswdtwo) {
- const forgotpassPayload = {
- username: response.data.result.userName,
- password: pswdtwo,
- };
- $("#forgot_password_details_submit").hide();
- $(".loader-btn").show();
- const forgetpassRes = await postAPIService(
- `account/UpdatePassword`,
- forgotpassPayload
- );
- console.log(forgetpassRes);
- $(".loader-btn").hide();
- $("#forgot_password_details_submit").show();
- window.localStorage.setItem('Ispasswordupdate',true)
- window.location.href = `./myaccount.html`;
- }else {
- $("#forgot-password-input-one").addClass('is-invalid');
- $("#forgot-password-input-two").addClass('is-invalid')
- $('.password_display').text('Passwords are not matched !').addClass('text-danger')
- }
-
-
- });
- }
- else{
- $('#forgot_User_Email').addClass('is-invalid');
- $('#forgot_User_Email').after(`<div class="invalid-feedback">Please enter Valid email</div>`);
-
- }
- }
- });
- $(".user_pass")
- .keyup(function () {
- // set password variable
- var pswd = $(this).val();
- passwordValidate(pswd);
- $('.pswd_info').hide();
- $(this).parent().siblings('.pswd_info').show();
- })
- .focus(function () {
- let pswdVal = $(this).val();
- let pattern = /^(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[^a-zA-Z0-9]).{8,}$/;
- if (pswdVal.match(pattern)) {
- $(this).parent().siblings('.pswd_info').hide();
- } else {
- $(this).parent().siblings('.pswd_info').show();
- }
- })
- .blur(function () {
- $(this).parent().siblings('.pswd_info').hide();
- });
-
- function toasterOpts(){
- toastr.options = {
- "closeButton": true,
- "debug": false,
- "newestOnTop": true,
- "progressBar": true,
- "positionClass": "toast-top-center",
- "preventDuplicates": true,
- "onclick": null,
- "showDuration": "300",
- "hideDuration": "1000",
- "timeOut": "5000",
- "extendedTimeOut": "1000",
- "showEasing": "swing",
- "hideEasing": "linear",
- "showMethod": "fadeIn",
- "hideMethod": "fadeOut"
- }
- }
- }
- $("#email_validate_submit").click(async function () {
- let vaidate_otp;
- let validate_email = $("#email_validation_input").val();
- if(validate_email == ''){
- $('#email_validation_input').addClass('is-invalid')
- $('#email_validation_input').after(`<div class="invalid-feedback">Please enter Valid email</div>`);
- return
- }
- else{
- debugger;
- let port = SERVERNAME;
- // let port = "http://localhost:3088";
- let url = `${port}/account/getuserbyphoneormail/${validate_email}/${validate_email}`;
- const config = {
- url,
- method: "get",
- };
- $(".loader-btn").show();
- $('#email_validate_submit').hide()
- let response = await axios(config);
- debugger;
- console.log(response);
- $(".loader-btn").hide();
- $('#email_validate_submit').show()
- if (response.data.result != null) {
- debugger;
- console.log(response.data);
- const forgotpassPayload = {
- firstname: "",
- lastname: "",
- contactnumber: "",
- email: "",
- tenantname: "",
- contactoremail: response.data.result.email,
- IsSignup: false,
- IsRegisterUser: false,
- IsForgotPswd: true,
- UnibaseId: response.data.result.userName,
- OtpId: 0,
- UserOtp: "",
- };
- $('#email_validate_submit').hide()
- $(".loader-btn").show();
- const validate_email_res = await postAPIService(
- `account/sendotp`,
- forgotpassPayload
- );
- $(".loader-btn").hide();
- vaidate_otp = validate_email_res.data;
- console.log(validate_email_res);
- $(".email-validation").hide();
- $('.user_email').html(validate_email)
- $(".otp-validation .otp-input-group").show();
- $(".otp-validation .otp-input-group").on("paste", function (p) {
- let data = p.originalEvent.clipboardData.getData("text");
- let dataLength = data.length;
- for (let i = 0; i < dataLength; i++) {
- let input = $(
- '.otp-validation .otp-input-group input[tabindex="' + (i + 1) + '"]'
- );
- input.val(data.charAt(i));
- if (input.val().length >= input.attr("maxlength")) {
- let nextInput = $(
- '.otp-validation .otp-input-group input[tabindex="' +
- (i + 2) +
- '"]'
- );
- if (nextInput) {
- nextInput.focus();
- }
- }
- }
- p.preventDefault();
- });
-
- }
- else{
- $('#email_validation_input').addClass('is-invalid');
- $('#email_validation_input').after(`<div class="invalid-feedback">Please enter Valid email</div>`);
-
- }
- }
- $("#email_validate_proceed").click(async function () {
- debugger;
- let userotp='';
- let validate_email = $("#email_validation_input").val();
- $(".email-validate-div .otp-validation .otp-input-group input").each(function () {
- let presVal = $(this).val();
- userotp += presVal;
- });
-
- if(userotp.length == 6){
- const validateForgotpass = {
- email: validate_email,
- otpid: vaidate_otp,
- userotp: userotp,
- };
- $('#email_validate_proceed').hide()
- $(".loader-btn").show();
- const validate_email_resopt = await postAPIService(
- `hyperfusion/validateotp`,
- validateForgotpass
- );
-
- $(".loader-btn").hide();
- $('#email_validate_proceed').show()
- const Resotp = validate_email_resopt.data.result;
- if (Resotp == "Otp verified successfully") {
- $(".login_section").show();
- $(".otp-validation .otp-input-group").hide();
- $("#email_validate_back").hide();
- $('.error_msg').hide();
- } else {
- // toasterOpts()
- // Command: toastr["error"]("Please enter Valid OTP");
- $('.error_msg').show();
- $('.error_msg .error_msg_res').html("Please enter Valid OTP");
- }
- }
- else{
- $('.error_msg').show();
- $('.error_msg .error_msg_res').html("Please enter OTP");
- }
- });
- });
-
-
- initLogin();
|