diff --git a/dist/Js/auth/apiservice.js b/dist/Js/auth/apiservice.js
index d922703..f71ebb6 100644
--- a/dist/Js/auth/apiservice.js
+++ b/dist/Js/auth/apiservice.js
@@ -1,14 +1,17 @@
//let SERVERNAME = 'https://anwi.bizgaze.app';
//let SERVERNAME = 'http://beta.bizgaze.com';
- let SERVERNAME = 'https://qa.anwisystems.com';
+let SERVERNAME = 'https://qa.anwisystems.com';
//let SERVERNAME = 'http://localhost:3088';
//template
-const STAT = '8041f78ba55b4847bc4aacaeae9d24ef';
+const STAT = 'd622a6ce4c8540ffadd0f885162ac8f4';
//live
//const STAT = '0c7ef2b000ca431290065753dfda56fe';
+const USER_AUTH_OKAY = 'USER_AUTH_OKAY';
+
+
function imgServerNameBuild(path){
return `https://appassets.bizgaze.app/${path}`;
}
@@ -29,9 +32,10 @@ async function getStatAPIService(url,data={}){
return response;
}
-async function getStatAPIService(url,data={}){
+async function getAPIService(url,data={}){
+ debugger
const config = {
- url,
+ url:`${SERVERNAME}/${url}`,
method: "get",
};
let response = await axios(config);
@@ -39,6 +43,18 @@ async function getStatAPIService(url,data={}){
return response;
}
+async function postAPIService(url,data={}){
+ let config = {
+ url:`${SERVERNAME}/${url}`,
+ method:'post',
+ data:data,
+ }
+ let response = await axios(config);
+
+ return response;
+}
+
+
async function postStatAPIService(url,data={}){
let config = {
url,
@@ -55,20 +71,7 @@ async function postStatAPIService(url,data={}){
}
-async function postAPIService(url,data={}){
- let config = {
- url:`${SERVERNAME}/${url}`,
- method:'post',
- data:data,
- // headers: {
- // 'Authorization': `Basic b67607dd-283e-478e-b2cf-35736e8bad69`,
- // 'Content-Type': 'application/json'
- // },
- }
- let response = await axios(config);
- return response;
-}
async function postAPIServiceLocal(url,data={}){
diff --git a/dist/Js/auth/login.js b/dist/Js/auth/login.js
index d93ba1c..bb4edb8 100644
--- a/dist/Js/auth/login.js
+++ b/dist/Js/auth/login.js
@@ -1,192 +1,443 @@
+
+
+let AUTH_LOGIN_APIS_URL = {
+ isUser(user) {
+ return `account/getuserbyphoneormail/${user}/${user}`;
+ },
+ login() {
+ return `bizgaze/crm/webapi/crmuserlogin`
+ },
+ signUp() {
+ return `bizgaze/crm/webapi/registercrmuser`;
+ },
+ resendOTP() {
+ return `bizgaze/crm/webapi/ReSendOtp`;
+ },
+ sendOTP() {
+ return `account/sendotp`;
+ },
+ updatePassword() {
+ return `account/UpdatePassword`;
+ }
+}
+
+initLogin();
+
+
+
+
+
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, Sign Up `);
- $(".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 + ' Validate Email');
- // toasterOpts();
- // Command: toastr["error"]()
- /*Email validation*/
- $('.validate_mail').click(function(){
- $(".login_section").hide();
- $(".email-validate-div").show();
- $('.error_msg').hide();
- })
- }
+
+ let userDetails = {
+ otpid: null,
+ email: null,
+ password: null,
+ unibaseid: null
+ }
+ let backotp = null;
+ let backOptions = {
+ forgotPassword:'forgotPassword',
+ EmailnotV:'EmailnotV',
+ signUp:'signUp'
+ }
+ let authloginLoadingBtnAction = {
+ addLoading() {
+ $('.authloginLoading').addClass('d-none');
+ $('.authloginLoadingBtn').removeClass('d-none');
+ },
+ removeLoading() {
+ $('.authloginLoading').removeClass('d-none');
+ $('.authloginLoadingBtn').addClass('d-none');
}
}
- // 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;
+ let otpLoadingAction = {
+ addLoadingOTP() {
+ $('.otploading').removeClass('d-none');
+ $('.otploadingtext').addClass('d-none');
+ },
+ removeLoadingOTP() {
+ $('.otploading').addClass('d-none');
+ $('.otploadingtext').removeClass('d-none');
+ }
+ }
+
+ let formErrorAction = {
+ addError(message) {
+ $('.error_msg').removeClass('d-none');
+ $('.error_msg_res').html(message);
+ },
+ removeClass() {
+ $('.error_msg').addClass('d-none');
+ $('.error_msg_res').html('');
+ }
+ }
+ function init() {
+ const logoauth = $('.logoauth');
+ logoauth.removeClass('d-none');
+ loginUI();
+ //updatePasswordUI();
+ //OTP_UI()
+ }
+
+
+ function checkPassword(value){
+ const specailHelper = containsSpecialCharsHelper(value);
+ const isUpperCase = isUpperCaseHelper(value);
+ const isLowerCase = isLowerCaseHelper(value);
+ const isNumber = isNumberContainsHelper(value);
+ const len = value.length>=8;
+
+ return specailHelper && isUpperCase && isLowerCase && isNumber && len;
+
+ }
+
+ init();
+
+ function updatePasswordUI() {
+ formErrorAction.removeClass();
+ let html = `
`;
+
+ $('.authContainerUI').html(html);
+ updatepasswordEvents();
+ }
+
+ function updatepasswordEvents() {
+
+ $('.needs-validation').off('submit');
+ loadPasswordListener();
+ $('.needs-validation').on('submit', async (event) => {
+ event.preventDefault();
+ let ele = document.querySelector('.needs-validation')
+ if (!ele.checkValidity()) {
+ ele.classList.add('was-validated')
+ return;
+ }
+
+
+ let newPassword = $('#updatepassword').val();
+ let passwordConfirm = $('#updateconfirmpassword').val();
+
+
+ if (newPassword != passwordConfirm) {
+ formErrorAction.addError("Password doesn't match");
+ return;
+ }
+
+ if(!checkPassword(newPassword)){
+ formErrorAction.addError("Password doesn't match");
+ return;
+ }
+
+ const forgotpassPayload = {
+ username: userDetails.unibaseid,
+ password: passwordConfirm,
+ };
+
+ const res = await postAPIService(AUTH_LOGIN_APIS_URL.updatePassword(), forgotpassPayload);
+
+ console.log(res);
+
+ if (res.data.message == 'Password Updated Successfully') {
+ loginUI();
+ toasterHelper("success", "Password updated successfull");
+ }
+ });
+
+
+ }
+
+ function loadPasswordListener(){
+
+ $('.passwordvalidui').off().on('keyup',function (e){
+ debugger;
+ $(this).parent().find('.pswd_info').css('display','block');
+ let value = $(this).val();
+
+ const specailHelper = containsSpecialCharsHelper(value);
+ const isUpperCase = isUpperCaseHelper(value);
+ const isLowerCase = isLowerCaseHelper(value);
+ const isNumber = isNumberContainsHelper(value);
+
+
+ if(isLowerCase){
+ $(this).parent().find('#chck_small').addClass('text-decoration-line-through');
+ }else{
+ $(this).parent().find('#chck_small').removeClass('text-decoration-line-through');
+ }
+
+ if(specailHelper){
+ $(this).parent().find('#chck_special').addClass('text-decoration-line-through');
+ }else{
+ $(this).parent().find('#chck_special').removeClass('text-decoration-line-through');
+ }
+
+ if(isUpperCase){
+ $(this).parent().find('#chck_capital').addClass('text-decoration-line-through');
+ }else{
+ $(this).parent().find('#chck_capital').removeClass('text-decoration-line-through');
+ }
+
+ if(value.length>=8){
+ $(this).parent().find('#chck_length').addClass('text-decoration-line-through');
+ }else{
+ $(this).parent().find('#chck_length').removeClass('text-decoration-line-through');
+ }
+
+ if(isNumber){
+ $(this).parent().find('#chck_number').addClass('text-decoration-line-through');
+ }else{
+ $(this).parent().find('#chck_number').removeClass('text-decoration-line-through');
+ }
+
+
+ }).blur(function (e){
+ $(this).parent().find('.pswd_info').css('display','none');
+ })
+
+ $('.eyePassword').off();
+ $('.eyePassword').click(function (e){
+ e.stopPropagation();
+ let eyeOpen = '';
+ let eyeClose = '';
+ console.log(this);
+ let isClose = $(this).find(`.fa-eye-slash`).length;
+
+ if(isClose){
+ $(this).html(eyeOpen);
+ $(this).parent().find('.passwordvalidui').attr('type','text');
+ }else{
+ $(this).html(eyeClose);
+ $(this).parent().find('.passwordvalidui').attr('type','password');
+ }
+ });
+ }
+
+ async function resendOTP() {
+ otpLoadingAction.addLoadingOTP();
+ let payload = {
+ "FirstName": "",
+ "LastName": "",
+ "ContactNumber": "",
+ "Email": "",
+ "TenantName": "",
+ "ContactOrEmail": userDetails.email,
+ "IsSignup": false,
+ "IsRegisterUser": true,
+ "IsForgotPswd": false,
+ "UnibaseId": userDetails.unibaseid,
+ "OtpId": parseInt(userDetails.otpid),
+ "UserOtp": ""
+ }
+ let res = await postAPIService(AUTH_LOGIN_APIS_URL.resendOTP(), payload);
+ res = res.data;
+ if (res.code != '0' || res.message != 'OTP resent successfully') {
+ return;
+ }
+ userDetails = { ...userDetails, otpid: res.result };
+ otpLoadingAction.removeLoadingOTP();
+ }
+
+ function loadForpasswordsEvents() {
+ $('.needs-validation').off('submit');
+ $('.needs-validation').on('submit', async (event) => {
+ event.preventDefault()
+ let ele = document.querySelector('.needs-validation')
+ if (!ele.checkValidity()) {
+ ele.classList.add('was-validated')
+ return;
+ }
+ debugger;
+
+ const email = $('#forgotpassword').val();
+
+ await sendOTPService(email,1,backOptions.forgotPassword);
+
+ authloginLoadingBtnAction.removeLoading();
+
+
+
+
+ });
+
+ $('.btnForgotback').click(function (e) {
+ loginUI();
+ })
+ }
+
+ function forgotPasswordUIEmail() {
+ formErrorAction.removeClass();
+ let html = ` Forgot Password?
Enter the email associated with your account and we'll send an email with instructions to reset your password.
`;
+ $('.authContainerUI').html(html);
+ loadForpasswordsEvents();
+ }
+
+
+
+ function loginEvents() {
+
+
+ // submit event
+ $('.needs-validation').off('submit');
+ $('.needs-validation').on('submit', async (event) => {
+ event.preventDefault();
+ let ele = document.querySelector('.needs-validation')
+ if (!ele.checkValidity()) {
+ ele.classList.add('was-validated')
+ return;
+ }
+
+
+ const email = $('#User_Email').val();
+
+ const isUserURL = AUTH_LOGIN_APIS_URL.isUser(email);
+ authloginLoadingBtnAction.addLoading();
+ const user = await getAPIService(isUserURL);
+ const isUser = user.data.result === null && user.data.message === `Email/Phonenumber doesn't exist`;
+
+ if (!isUser) {
+ loginUser();
+ } else {
+ signUpUser();
+ }
+ });
+
+ // forgot password
+ $('.forgotpasswordBtn').click(function (e) {
+ forgotPasswordUIEmail();
+ });
+
+
+
+ loadPasswordListener();
+
+
+
+
+ }
+
+
+
+ async function loginUserService(email, passord) {
+ const loginPayload = {
+ username: email,
+ Password: passord,
+ UnibaseId: "",
+ RememberMe: false,
+ };
+
+ let res = await postAPIService(AUTH_LOGIN_APIS_URL.login(),
+ loginPayload
+ );
+
+ return res;
+ }
+
+ async function loginUser() {
+ formErrorAction.removeClass();
+ let userEmail = $("#User_Email").val();
+ let userPassword = $("#User_password").val();
+
+
+ let res = await loginUserService(userEmail, userPassword);
+ res = res.data;
+
+ let isError = res.code != '0';
+
+
+ userDetails['email'] = userEmail;
+ userDetails['password'] = userPassword;
+ debugger;
+ if (isError) {
+ if (res.message === 'Email is not verified') {
+ formErrorAction.addError(`${res.message} Valid here`);
+
+ $('.validemail').off('click')
+ $('.validemail').click(async function (e) {
+ await sendOTPService(userEmail,2,backOptions.EmailnotV);
+ formErrorAction.removeClass();
+ authloginLoadingBtnAction.removeLoading();
+
+ });
+ authloginLoadingBtnAction.removeLoading();
+ return;
+ }
+
+ formErrorAction.addError(`${res.message}`);
+ authloginLoadingBtnAction.removeLoading();
+ return;
+ }
+
+ COOKIE_HELPER_ACTIONS.setCookie({
+ token: res.result.sessionId,
+ userid: res.result.userId,
+ ...res.result
+ });
+
+ const isCartAdded = localStorage.getItem(CART_ADD);
+ if(isCartAdded){
+ localStorage.removeItem(CART_ADD);
+ window.location.href = `/selectdelivery.html`;
+ return;
+ }
+ localStorage.setItem(USER_AUTH_OKAY,2);
+ window.location.href = '/';
+ //authloginLoadingBtnAction.removeLoading();
+ console.log(res);
+ }
+
+ async function sendOTPService(userEmail,num=0,option) {
+ const isUserURL = AUTH_LOGIN_APIS_URL.isUser(userEmail);
+ authloginLoadingBtnAction.addLoading();
+ const user = await getAPIService(isUserURL);
+ const isUser = user.data.result === null || user.data.message === `Email/Phonenumber doesn't exist`;
+ if (isUser) {
+ formErrorAction.addError(user.data.message);
+ authloginLoadingBtnAction.removeLoading();
+ return;
+ }
+
+ const forgotpassPayload = {
+ firstname: "",
+ lastname: "",
+ contactnumber: "",
+ email: "",
+ tenantname: "",
+ contactoremail: user.data.result.email,
+ IsSignup: false,
+ IsRegisterUser: false,
+ IsForgotPswd: true,
+ UnibaseId: user.data.result.userName,
+ OtpId: 0,
+ UserOtp: "",
+ };
+
+ const forgetpassRes = await postAPIService(
+ AUTH_LOGIN_APIS_URL.sendOTP(),
+ forgotpassPayload
+ );
+
+ userDetails.email = userEmail;
+ userDetails.otpid = forgetpassRes.data;
+ userDetails.unibaseid = user.data.result.userName;
+
+ console.log(forgetpassRes, userDetails);
+ backotp = option
+ OTP_UI(num);
+
+ }
+
+ async function signUpUser() {
+ formErrorAction.removeClass();
+ let userEmail = $("#User_Email").val();
+ let userPassword = $("#User_password").val();
+ let checkPasswordValue = checkPassword(userPassword);
+ if(!checkPasswordValue){
+ authloginLoadingBtnAction.removeLoading();
+ formErrorAction.addError('Password must contain one specail letter ,number,small letter, uppercase letter and 8 letters');
+ return;
+ }
const userRegistratioNPayload = {
organizationtypeid: "2",
organizationid: "0",
@@ -194,10 +445,10 @@ function initLogin() {
userid: "0",
username: "0",
users_phonenumber: "0",
- password: reg_pwd,
+ password: userPassword,
users_emailaddress: "0",
- emailaddress: reg_email,
- contactname: userName[0],
+ emailaddress: userEmail,
+ contactname: userEmail.split('@')[0],
phonenumber: "0",
branchid: "0",
tenantname: "Anwi Systems",
@@ -205,576 +456,246 @@ function initLogin() {
currencyid: "0",
customerformuniqueid: "Bizgaze_Platform_Crm_RegisterCRMUser",
};
- debugger;
- $('#register_btn').hide()
- $(".loader-btn").show();
- debugger;
- const res = await postAPIService(
- `bizgaze/crm/webapi/registercrmuser`,
+
+ let res = await postAPIService(
+ AUTH_LOGIN_APIS_URL.signUp(),
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);
+
+ console.log(res);
+
+ res = res.data;
+ if (res.code != '0') {
+ formErrorAction.addError(res.message);
+ authloginLoadingBtnAction.removeLoading();
return;
}
- else {
- $("#register_form .email-password-group").hide();
- $("#register_form .register_otp.otp-input-group").show();
- }
+
+ res = res.result;
+
+ userDetails['otpid'] = res.OtpId;
+ userDetails['email'] = userEmail;
+ userDetails['password'] = userPassword;
+ userDetails['unibaseid'] = res.UnibaseId;
+ backotp = backOptions.signUp
+ OTP_UI();
- $("#proceed").click(async function () {
- let userEnterOtp = "";
- let userEmail = registerForm.find("#User_Email").val();
- $(".otp-input-group input").each(function () {
+
+ }
+
+
+ function loginUI() {
+ formErrorAction.removeClass();
+ let html = `
+ Sign Up or Login
+
+
+
+ Forgot password?
+
+ `;
+ $('.authContainerUI').html(html);
+
+ loginEvents();
+ }
+
+ function OTP_UI(forgot = 0) {
+ formErrorAction.removeClass();
+ let html = `
+
+
+
+
+
`;
+ $('.authContainerUI').html(html);
+ loadOTPEvents(forgot);
+ }
+
+ async function validOTP(email, id, otp) {
+ const validateForgotpass = {
+ email: email,
+ otpid: id,
+ userotp: otp,
+ };
+
+ const res = await postAPIService(
+ `hyperfusion/validateotp`,
+ validateForgotpass
+ );
+
+ return res;
+ }
+
+ function loadOTPEvents(forgot) {
+
+
+ $('.resendOTP').click(function (e) {
+ resendOTP();
+ })
+
+
+ $('.btnForgotback').off().click(function(e){
+ debugger;
+ if(backotp === backOptions.forgotPassword){
+ forgotPasswordUIEmail();
+ }else if(backotp === backOptions.EmailnotV){
+ loginUI();
+ }else if(backotp === backOptions.signUp){
+ loginUI();
+ }
+ });
+
+ $("#email_validate_proceed").click(async function () {
+ debugger;
+ otpLoadingAction.addLoadingOTP();
+ let userotp = '';
+ $(".otp-validation .otp-input-group input").each(function () {
let presVal = $(this).val();
- userEnterOtp += presVal;
+ userotp += 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();
+
+ if (userotp.length == 6) {
+ // const validateForgotpass = {
+ // email: userDetails.email,
+ // otpid: userDetails.otpid,
+ // userotp: userotp,
+ // };
+ $('#email_validate_proceed').hide()
+ $(".loader-btn").show();
+ const validate_email_resopt = await validOTP(userDetails.email, userDetails.otpid, userotp);
+
+ $(".loader-btn").hide();
+ $('#email_validate_proceed').show()
+ const Resotp = validate_email_resopt.data.result;
+ if (Resotp == "Otp verified successfully") {
+ if (forgot == 1) {
+ updatePasswordUI();
+ return;
+ } else if (forgot == 2) {
+ loginUI();
+ toasterHelper("success", "Email has been verified");
+ return;
+ }
+ const res = await loginUserService(userDetails.email, userDetails.password);
+
+
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`;
+ localStorage.setItem(USER_AUTH_OKAY,1);
+ window.location.href = '/';
+ otpLoadingAction.removeLoadingOTP();
} 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')
- }
-})
+ // toasterOpts()
+ // Command: toastr["error"]("Please enter Valid OTP");
+ otpLoadingAction.removeLoadingOTP();
+ formErrorAction.addError("Please enter Valid OTP")
- $("#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(`Please enter Valid email
`);
-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(`Please enter Valid email
`);
-
- }
- }
- });
- $(".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(`Please enter Valid email
`);
-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(`Please enter Valid email
`);
-
- }
- }
- $("#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;
+ }
+ else {
+ otpLoadingAction.removeLoadingOTP();
+ formErrorAction.addError("Please enter Valid OTP")
+ }
});
-
- 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");
- }
- });
- });
+ $(".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();
+ });
-initLogin();
+ $('.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();
+ }
+ }
+ }
+ );
+ }
+}
\ No newline at end of file
diff --git a/dist/Js/footer.js b/dist/Js/footer.js
index cc07326..ef1d087 100644
--- a/dist/Js/footer.js
+++ b/dist/Js/footer.js
@@ -26,7 +26,7 @@ $(document).ready(function () {