🔥 The free & Open Source DocuSign alternative
JavaScript digital-signaturedocument-signingdocusign-alternativedocusign-freee-signatureelectronic-signatureelectronic-signaturesesignesignaturehacktoberfestjavascriptlegaltechmongodbnodejsopen-sourcepdf-signpdf-signaturereactjsself-hostedsign-pdf-files
fix: restrict user from logging in when next renewal date is expired even when route is entered directly
prafull-opensignlabs3115ff3e2a97
diff --git a/apps/OpenSign/src/layout/HomeLayout.js b/apps/OpenSign/src/layout/HomeLayout.jsindex b13a51a6a..43565a80f 100644--- a/apps/OpenSign/src/layout/HomeLayout.js+++ b/apps/OpenSign/src/layout/HomeLayout.js@@ -34,7 +34,6 @@ const HomeLayout = () => {});if (user) {checkIsSubscribed();- setIsLoader(false);} else {setIsUserValid(false);}@@ -48,10 +47,6 @@ const HomeLayout = () => {async function checkIsSubscribed() {const currentUser = Parse.User.current();- // const userSettings = appInfo.settings;- // const setting = userSettings.find((x) => x.role === _currentRole);- // const redirectUrl =- // location?.state?.from || `/${setting.pageType}/${setting.pageId}`;const user = await Parse.Cloud.run("getUserDetails", {email: currentUser.get("email")});@@ -59,24 +54,12 @@ const HomeLayout = () => {if (_user.TenantId) {localStorage.setItem("TenetId", _user.TenantId.objectId);}- // localStorage.setItem("PageLanding", setting.pageId);- // localStorage.setItem("defaultmenuid", setting.menuId);- // localStorage.setItem("pageType", setting.pageType);if (process.env.REACT_APP_ENABLE_SUBSCRIPTION) {- // const LocalUserDetails = {- // name: _user.Name,- // email: _user.Email,- // phone: _user.Phone,- // company: _user.Company- // };- // localStorage.setItem("userDetails", JSON.stringify(LocalUserDetails));const billingDate = _user.Next_billing_date && _user.Next_billing_date;if (billingDate) {if (billingDate > new Date()) {- // localStorage.removeItem("userDetails");- // Redirect to the appropriate URL after successful login- // navigate(redirectUrl);setIsUserValid(true);+ setIsLoader(false);return true;} else {navigate(`/subscription`);@@ -86,9 +69,8 @@ const HomeLayout = () => {}} else {setIsUserValid(true);+ setIsLoader(false);return true;- // Redirect to the appropriate URL after successful login- // navigate(redirectUrl);}}const showSidebar = () => {@@ -244,7 +226,7 @@ const HomeLayout = () => {return (<div><div className="sticky top-0 z-50">- <Header showSidebar={showSidebar} />+ {!isLoader && <Header showSidebar={showSidebar} />}</div>{isUserValid ? (<>@@ -269,7 +251,6 @@ const HomeLayout = () => {<><div className="flex md:flex-row flex-col z-50"><Sidebar isOpen={isOpen} closeSidebar={closeSidebar} />-<divid="renderList"className="relative h-screen flex flex-col justify-between w-full overflow-y-auto"diff --git a/apps/OpenSign/src/pages/PlanSubscriptions.js b/apps/OpenSign/src/pages/PlanSubscriptions.jsindex db39ee465..3a2e398bc 100644--- a/apps/OpenSign/src/pages/PlanSubscriptions.js+++ b/apps/OpenSign/src/pages/PlanSubscriptions.js@@ -1,5 +1,5 @@import React, { useState, useEffect } from "react";-import { useNavigate } from "react-router";+// import { useNavigate } from "react-router";import { NavLink } from "react-router-dom";import checkmark from "../assets/images/checkmark.png";import plansArr from "../json/plansArr.json";@@ -13,7 +13,7 @@ const listItemStyle = {};const PlanSubscriptions = () => {- const navigate = useNavigate();+ // const navigate = useNavigate();const [yearlyVisible, setYearlyVisible] = useState(false);const [isLoader, setIsLoader] = useState(true);@@ -35,12 +35,12 @@ const PlanSubscriptions = () => {company +phone;useEffect(() => {- if (localStorage.getItem("accesstoken")) {+ // if (localStorage.getItem("accesstoken")) {setIsLoader(false);setYearlyVisible(false);- } else {- navigate("/", { replace: true });- }+ // } else {+ // navigate("/", { replace: true });+ // }// eslint-disable-next-line}, []);@@ -108,7 +108,7 @@ const PlanSubscriptions = () => {: ""} text-sm text-center my-2`}>- <p+ <divstyle={{backgroundColor: item.subtitlecolor? item.subtitlecolor@@ -124,7 +124,7 @@ const PlanSubscriptions = () => {) : (<span>{item.subtitle}</span>)}- </p>+ </div></div></div>diff --git a/apps/OpenSign/src/primitives/Validate.js b/apps/OpenSign/src/primitives/Validate.jsindex 86993d8b3..21fd208c5 100644--- a/apps/OpenSign/src/primitives/Validate.js+++ b/apps/OpenSign/src/primitives/Validate.js@@ -15,7 +15,7 @@ const Validate = () => {sessionToken: localStorage.getItem("accesstoken")});if (user) {- setIsUserValid(true);+ checkIsSubscribed();} else {setIsUserValid(false);}@@ -24,7 +24,33 @@ const Validate = () => {setIsUserValid(false);}})();+ // eslint-disable-next-line react-hooks/exhaustive-deps}, []);++ async function checkIsSubscribed() {+ const currentUser = Parse.User.current();+ console.log("currentUser ", currentUser)+ const user = await Parse.Cloud.run("getUserDetails", {+ email: currentUser.get("email")+ });+ const _user = user?.toJSON();++ if (process.env.REACT_APP_ENABLE_SUBSCRIPTION) {+ const billingDate = _user.Next_billing_date && _user.Next_billing_date;+ if (billingDate) {+ if (billingDate > new Date()) {+ setIsUserValid(true);+ return true;+ } else {+ // navigate(`/subscription`);+ }+ } else {+ // navigate(`/subscription`);+ }+ } else {+ setIsUserValid(true);+ }+ }const handleLoginBtn = () => {try {Parse.User.logOut();