diff --git a/apps/OpenSign/src/components/LoginGoogle.js b/apps/OpenSign/src/components/LoginGoogle.js index 96e97c1b0..469352b52 100644 --- a/apps/OpenSign/src/components/LoginGoogle.js +++ b/apps/OpenSign/src/components/LoginGoogle.js @@ -115,8 +115,8 @@ const GoogleSignInBtn = ({ // console.log("payload ", payload); if (payload && payload.sessiontoken) { // setThirdpartyLoader(true); - const billingDate = - extRes.get("Next_billing_date") && extRes.get("Next_billing_date"); + // const billingDate = + // extRes.get("Next_billing_date") && extRes.get("Next_billing_date"); // console.log("billingDate expired", billingDate > new Date()); const LocalUserDetails = { name: details.Name, @@ -125,7 +125,7 @@ const GoogleSignInBtn = ({ company: extRes.get("Company") }; localStorage.setItem("userDetails", JSON.stringify(LocalUserDetails)); - thirdpartyLoginfn(payload.sessiontoken, billingDate); + thirdpartyLoginfn(payload.sessiontoken); } return { msg: "exist" }; } else { diff --git a/apps/OpenSign/src/pages/Login.js b/apps/OpenSign/src/pages/Login.js index 2b050dab1..a2e4b401c 100644 --- a/apps/OpenSign/src/pages/Login.js +++ b/apps/OpenSign/src/pages/Login.js @@ -422,7 +422,7 @@ function Login() { alert("Somenthing went wrong, please try again later!"); } }; - const thirdpartyLoginfn = async (sessionToken, billingDate) => { + const thirdpartyLoginfn = async (sessionToken) => { const baseUrl = localStorage.getItem("baseUrl"); const parseAppId = localStorage.getItem("parseAppId"); const res = await axios.get(baseUrl + "users/me", { @@ -521,7 +521,7 @@ function Login() { await Parse.Cloud.run("getUserDetails", { email: currentUser.get("email") }).then( - (result) => { + async (result) => { let tenentInfo = []; const results = [result]; if (results) { @@ -571,7 +571,7 @@ function Login() { setState({ ...state, loading: false }); navigate("/"); } else { - extendedInfo.forEach((x) => { + extendedInfo.forEach(async (x) => { if (x.TenantId) { let obj = { tenentId: x.TenantId.objectId, @@ -608,8 +608,13 @@ function Login() { setThirdpartyLoader(false); setState({ ...state, loading: false }); if (isEnableSubscription) { - if (billingDate) { - if (billingDate > new Date()) { + const res = await fetchSubscription(); + const freeplan = res.plan; + const billingDate = res.billingDate; + if (freeplan === "freeplan") { + navigate(redirectUrl); + } else if (billingDate) { + if (new Date(billingDate) > new Date()) { localStorage.removeItem("userDetails"); navigate(redirectUrl); } else { @@ -644,8 +649,13 @@ function Login() { setState({ ...state, loading: false }); setThirdpartyLoader(false); if (isEnableSubscription) { - if (billingDate) { - if (billingDate > new Date()) { + const res = await fetchSubscription(); + const freeplan = res.plan; + const billingDate = res.billingDate; + if (freeplan === "freeplan") { + navigate(redirectUrl); + } else if (billingDate) { + if (new Date(billingDate) > new Date()) { localStorage.removeItem("userDetails"); // Redirect to the appropriate URL after successful login navigate(redirectUrl);