- {isLoading.isLoad ? (
-
- ) : handleError ? (
-
+ {isSubscribed ? (
+
+
+
+ Owner's subscription has expired.
+
+
+
) : (
-
- {isUiLoading && (
-
-
-
- This might take some time
-
-
- )}
-
-
-
{
- setIsAlert({
- isShow: false,
- alertMessage: ""
- });
- }}
- >
-
-
{isAlert.alertMessage}
-
+ <>
+ {isLoading.isLoad ? (
+
+ ) : handleError ? (
+
+ ) : (
+
+ {isUiLoading && (
+ >
+
+
+ This might take some time
+
+
+ )}
-
{
+
+ {
setIsAlert({
isShow: false,
alertMessage: ""
});
}}
- type="button"
- className="finishBtn cancelBtn"
>
- Ok
-
-
-
+
+
{isAlert.alertMessage}
-
-
- {/* this modal is used to show decline alert */}
-
- {/* this modal is used for show expired alert */}
-
-
-
{
- setDefaultSignAlert({
- isShow: false,
- alertMessage: ""
- });
- }}
- >
-
-
{defaultSignAlert.alertMessage}
-
-
- {defaultSignImg ? (
- <>
-
addDefaultSignature()}
+
- Yes
-
+ >
+
{
- setDefaultSignAlert({
+ setIsAlert({
isShow: false,
alertMessage: ""
});
@@ -1064,327 +1028,423 @@ function PdfRequestFiles() {
type="button"
className="finishBtn cancelBtn"
>
- Close
+ Ok
- >
- ) : (
- {
- setIsAlert({
- isShow: false,
- alertMessage: ""
- });
- }}
- type="button"
- className="finishBtn cancelBtn"
- >
- Ok
-
- )}
-
-
- {/* this component used to render all pdf pages in left side */}
-
+
+
- {/* pdf render view */}
- 500 && "20px",
- marginRight: !isMobile && pdfOriginalWidth > 500 && "20px"
- }}
- >
- {/* this modal is used show this document is already sign */}
-
{
- setIsCompleted({ isModal: false, isCertificate: true });
- }}
- >
-
-
This document has been signed by all Signers.
+
-
-
- setIsCompleted({ isModal: false, isCertificate: true })
- }
- >
- Close
-
-
-
+ {/* this modal is used to show decline alert */}
+
+ {/* this modal is used for show expired alert */}
+
- {/* this component is used for signature pad modal */}
-
- {/* pdf header which contain funish back button */}
-
- {containerWH && (
-
{
+ setDefaultSignAlert({
+ isShow: false,
+ alertMessage: ""
+ });
+ }}
+ >
+
+
{defaultSignAlert.alertMessage}
+
+
+ {defaultSignImg ? (
+ <>
+
addDefaultSignature()}
+ style={{
+ background: themeColor
+ }}
+ type="button"
+ className="finishBtn"
+ >
+ Yes
+
+
{
+ setDefaultSignAlert({
+ isShow: false,
+ alertMessage: ""
+ });
+ }}
+ type="button"
+ className="finishBtn cancelBtn"
+ >
+ Close
+
+ >
+ ) : (
+
{
+ setIsAlert({
+ isShow: false,
+ alertMessage: ""
+ });
+ }}
+ type="button"
+ className="finishBtn cancelBtn"
+ >
+ Ok
+
+ )}
+
+
+ {/* this component used to render all pdf pages in left side */}
+
- )}
-
-
-
+
+ {/* pdf render view */}
500 && "20px",
+ marginRight: !isMobile && pdfOriginalWidth > 500 && "20px"
+ }}
>
- {signedSigners.length > 0 && (
- <>
+ {/* this modal is used show this document is already sign */}
+
{
+ setIsCompleted({ isModal: false, isCertificate: true });
+ }}
+ >
+
+
This document has been signed by all Signers.
+
+
+ setIsCompleted({
+ isModal: false,
+ isCertificate: true
+ })
+ }
>
- Signed by
-
-
- {signedSigners.map((obj, ind) => {
- return (
-
-
-
+
+
+
+ {/* this component is used for signature pad modal */}
+
+ {/* pdf header which contain funish back button */}
+
+ {containerWH && (
+
+ )}
+
+
+
+
+ {signedSigners.length > 0 && (
+ <>
+
+ Signed by
+
+
+ {signedSigners.map((obj, ind) => {
+ return (
+
- {getFirstLetter(obj.Name)}
-
-
-
- {obj.Name}
- {obj.Email}
-
-
- );
- })}
-
- >
- )}
+
+
+ {getFirstLetter(obj.Name)}
+
+
+
+ {obj.Name}
+
+ {obj.Email}
+
+
+
+ );
+ })}
+
+ >
+ )}
- {unsignedSigners.length > 0 && (
- <>
-
0 && "20px"
- }}
- >
- Yet to sign
-
-
- {unsignedSigners.map((obj, ind) => {
- return (
-
-
-
0 && (
+ <>
+ 0 && "20px"
+ }}
+ >
+ Yet to sign
+
+
+ {unsignedSigners.map((obj, ind) => {
+ return (
+
- {getFirstLetter(obj.Name)}
-
-
-
- {obj.Name}
- {obj.Email}
-
-
-
- );
- })}
-
- >
- )}
- {defaultSignImg && !alreadySign && (
-
- )}
+
+
+ {getFirstLetter(obj.Name)}
+
+
+
+ {obj.Name}
+
+ {obj.Email}
+
+
+
+
+ );
+ })}
+
+ >
+ )}
+ {defaultSignImg && !alreadySign && (
+
+ )}
+
+
-
-
- )}
-
-
{
- setValidateAlert(false);
- }}
- >
-
-
- The input does not meet the criteria set by the regular expression.
-
+ )}
-
{
+ setValidateAlert(false);
}}
- >
-
setValidateAlert(false)}
- type="button"
- className="finishBtn cancelBtn"
>
- Close
-
-
-
+
+
+ The input does not meet the criteria set by the regular
+ expression.
+
+
+
+
setValidateAlert(false)}
+ type="button"
+ className="finishBtn cancelBtn"
+ >
+ Close
+
+
+
+ >
+ )}
);
}
diff --git a/apps/OpenSign/src/pages/Pgsignup.js b/apps/OpenSign/src/pages/Pgsignup.js
index 10b270d1e..f34cf9d7b 100644
--- a/apps/OpenSign/src/pages/Pgsignup.js
+++ b/apps/OpenSign/src/pages/Pgsignup.js
@@ -353,7 +353,7 @@ const PgSignUp = () => {
tenentName: x.TenantId.TenantName || ""
};
localStorage.setItem(
- "TenetId",
+ "TenantId",
x.TenantId.objectId
);
tenentInfo.push(obj);
diff --git a/apps/OpenSign/src/pages/PlaceHolderSign.js b/apps/OpenSign/src/pages/PlaceHolderSign.js
index b152c8cf8..2162b3202 100644
--- a/apps/OpenSign/src/pages/PlaceHolderSign.js
+++ b/apps/OpenSign/src/pages/PlaceHolderSign.js
@@ -3,7 +3,7 @@ import axios from "axios";
import Parse from "parse";
import "../styles/signature.css";
import { PDFDocument } from "pdf-lib";
-import { themeColor } from "../constant/const";
+import { isEnableSubscription, themeColor } from "../constant/const";
import { DndProvider } from "react-dnd";
import { HTML5Backend } from "react-dnd-html5-backend";
import { useDrag, useDrop } from "react-dnd";
@@ -39,6 +39,7 @@ import TourContentWithBtn from "../primitives/TourContentWithBtn";
import ModalUi from "../primitives/ModalUi";
import DropdownWidgetOption from "../components/pdf/DropdownWidgetOption";
import WidgetNameModal from "../components/pdf/WidgetNameModal";
+import { SaveFileSize } from "../constant/saveFileSize";
function PlaceHolderSign() {
const navigate = useNavigate();
@@ -104,11 +105,12 @@ function PlaceHolderSign() {
const [widgetName, setWidgetName] = useState(false);
const [mailStatus, setMailStatus] = useState("");
const [isCurrUser, setIsCurrUser] = useState(false);
+ const [isSubscribe, setIsSubscribe] = useState(false);
const [isAlreadyPlace, setIsAlreadyPlace] = useState({
status: false,
message: ""
});
-
+ const [extUserId, setExtUserId] = useState("");
const isMobile = window.innerWidth < 767;
const [, drop] = useDrop({
accept: "BOX",
@@ -180,11 +182,35 @@ function PlaceHolderSign() {
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [divRef.current]);
+ async function checkIsSubscribed(email) {
+ const user = await Parse.Cloud.run("getUserDetails", {
+ email: email
+ });
+ const freeplan = user?.get("Plan") && user?.get("Plan").plan_code;
+ const billingDate =
+ user?.get("Next_billing_date") && user?.get("Next_billing_date");
+ if (freeplan === "freeplan") {
+ return true;
+ } else if (billingDate) {
+ if (billingDate > new Date()) {
+ setIsSubscribe(true);
+ return true;
+ } else {
+ navigate(`/subscription`);
+ }
+ } else {
+ navigate(`/subscription`);
+ }
+ }
//function for get document details
const getDocumentDetails = async () => {
//getting document details
const documentData = await contractDocument(documentId);
if (documentData && documentData.length > 0) {
+ setExtUserId(documentData[0]?.ExtUserPtr?.objectId);
+ if (isEnableSubscription) {
+ checkIsSubscribed(documentData[0]?.ExtUserPtr?.Email);
+ }
const alreadyPlaceholder = documentData[0]?.SignedUrl;
// Check if document is sent for signing
if (alreadyPlaceholder) {
@@ -736,6 +762,9 @@ function PlaceHolderSign() {
// Save the Parse File if needed
const pdfData = await pdfFile.save();
const pdfUrl = pdfData.url();
+ const tenantId = localStorage.getItem("TenantId");
+ const buffer = atob(pdfBytes);
+ SaveFileSize(buffer.length, pdfUrl, tenantId);
return pdfUrl;
} catch (e) {
console.log("error", e);
@@ -829,6 +858,7 @@ function PlaceHolderSign() {
: "";
const themeBGcolor = themeColor;
let params = {
+ extUserId: extUserId,
recipient: signerMail[i].Email,
subject: `${pdfDetails?.[0].ExtUserPtr.Name} has requested you to sign ${pdfDetails?.[0].Name}`,
from: sender,
@@ -1596,6 +1626,7 @@ function PlaceHolderSign() {
currWidgetsDetails={currWidgetsDetails}
setCurrWidgetsDetails={setCurrWidgetsDetails}
handleClose={handleNameModal}
+ isSubscribe={isSubscribe}
/>
{/* pdf header which contain funish back button */}
@@ -1831,6 +1864,7 @@ function PlaceHolderSign() {
isOpen={isNameModal}
handleClose={handleNameModal}
handleData={handleWidgetdefaultdata}
+ isSubscribe={isSubscribe}
/>
>
diff --git a/apps/OpenSign/src/pages/PlanSubscriptions.js b/apps/OpenSign/src/pages/PlanSubscriptions.js
index db39ee465..d68a85fc6 100644
--- a/apps/OpenSign/src/pages/PlanSubscriptions.js
+++ b/apps/OpenSign/src/pages/PlanSubscriptions.js
@@ -1,9 +1,9 @@
import React, { useState, useEffect } from "react";
-import { useNavigate } from "react-router";
-import { NavLink } from "react-router-dom";
+import { NavLink, useNavigate } from "react-router-dom";
import checkmark from "../assets/images/checkmark.png";
import plansArr from "../json/plansArr.json";
import Title from "../components/Title";
+import Parse from "parse";
const listItemStyle = {
paddingLeft: "20px", // Add padding to create space for the image
backgroundImage: `url(${checkmark})`, // Set your image as the list style image
@@ -35,15 +35,35 @@ const PlanSubscriptions = () => {
company +
phone;
useEffect(() => {
- if (localStorage.getItem("accesstoken")) {
- setIsLoader(false);
- setYearlyVisible(false);
- } else {
- navigate("/", { replace: true });
- }
+ // if (localStorage.getItem("accesstoken")) {
+ setIsLoader(false);
+ // } else {
+ // navigate("/", { replace: true });
+ // }
// eslint-disable-next-line
}, []);
+ const handleFreePlan = async () => {
+ setIsLoader(true);
+ try {
+ const params = { userId: Parse.User.current().id };
+ const res = await Parse.Cloud.run("freesubscription", params);
+ if (res.status === "success" && res.result === "already subscribed!") {
+ setIsLoader(false);
+ alert("You have already subscribed to plan!");
+ } else if (res.status === "success") {
+ setIsLoader(false);
+ navigate("/");
+ } else if (res.status === "error") {
+ setIsLoader(false);
+ alert(res.result);
+ }
+ } catch (err) {
+ setIsLoader(false);
+ console.log("err in free subscribe", err.message);
+ alert("Somenthing went wrong, please try again later!");
+ }
+ };
return (
<>
@@ -69,23 +89,40 @@ const PlanSubscriptions = () => {
style={{
backgroundColor: "white",
overflowY: "auto",
- maxHeight: "100%",
- "--theme-color": "#7952b3",
- "--plan-width": 30
+ maxHeight: "100%"
}}
>
-
-
)}
diff --git a/apps/OpenSign/src/pages/Signup.js b/apps/OpenSign/src/pages/Signup.js
index 620db1632..a3af7263c 100644
--- a/apps/OpenSign/src/pages/Signup.js
+++ b/apps/OpenSign/src/pages/Signup.js
@@ -2,17 +2,19 @@ import React, { useState, useEffect } from "react";
import Parse from "parse";
import axios from "axios";
import Title from "../components/Title";
-import { useNavigate, NavLink } from "react-router-dom";
+import { useNavigate, NavLink, useLocation } from "react-router-dom";
import login_img from "../assets/images/login_img.svg";
import { useWindowSize } from "../hook/useWindowSize";
import Alert from "../primitives/Alert";
import { appInfo } from "../constant/appinfo";
import { useDispatch } from "react-redux";
import { fetchAppInfo } from "../redux/reducers/infoReducer";
-import { showTenant } from "../redux/reducers/ShowTenant";
+import { showTenant } from "../redux/reducers/ShowTenant";
+import { isEnableSubscription } from "../constant/const";
const Signup = () => {
const { width } = useWindowSize();
const navigate = useNavigate();
+ const location = useLocation();
const dispatch = useDispatch();
const [name, setName] = useState("");
const [phone, setPhone] = useState("");
@@ -67,6 +69,19 @@ const Signup = () => {
localStorage.setItem("baseUrl", baseUrl);
localStorage.setItem("parseAppId", appid);
};
+
+ const handleFreePlan = async (id) => {
+ try {
+ const params = { userId: id };
+ const res = await Parse.Cloud.run("freesubscription", params);
+ if (res.status === "error") {
+ alert(res.result);
+ }
+ } catch (err) {
+ console.log("err in free subscribe", err.message);
+ alert("Somenthing went wrong, please try again later!");
+ }
+ };
const handleSubmit = (event) => {
event.preventDefault();
if (lengthValid && caseDigitValid && specialCharValid) {
@@ -110,7 +125,13 @@ const Signup = () => {
params
);
if (usersignup) {
- handleNavigation(r.getSessionToken());
+ const param = new URLSearchParams(location.search);
+ const isFreeplan =
+ param?.get("subscription") === "freeplan";
+ if (isFreeplan) {
+ await handleFreePlan(r.id);
+ }
+ handleNavigation(r.getSessionToken(), isFreeplan);
}
} catch (err) {
alert(err.message);
@@ -155,7 +176,7 @@ const Signup = () => {
}
};
- const handleNavigation = async (sessionToken) => {
+ const handleNavigation = async (sessionToken, isFreeplan = false) => {
const baseUrl = localStorage.getItem("baseUrl");
const parseAppId = localStorage.getItem("parseAppId");
const res = await axios.get(baseUrl + "users/me", {
@@ -259,9 +280,7 @@ const Signup = () => {
});
if (tenentInfo.length) {
dispatch(
- showTenant(
- tenentInfo[0].tenentName || ""
- )
+ showTenant(tenentInfo[0].tenentName || "")
);
localStorage.setItem(
"TenantName",
@@ -297,7 +316,7 @@ const Signup = () => {
tenentName: x.TenantId.TenantName || ""
};
localStorage.setItem(
- "TenetId",
+ "TenantId",
x.TenantId.objectId
);
tenentInfo.push(obj);
@@ -325,8 +344,14 @@ const Signup = () => {
element.pageType
);
setState({ loading: false });
- if (process.env.REACT_APP_ENABLE_SUBSCRIPTION) {
- navigate(`/subscription`, { replace: true });
+ if (isEnableSubscription) {
+ if (isFreeplan) {
+ navigate(
+ `/${element.pageType}/${element.pageId}`
+ );
+ } else {
+ navigate(`/subscription`, { replace: true });
+ }
} else {
alert("Registered user successfully");
navigate(
@@ -343,8 +368,14 @@ const Signup = () => {
);
localStorage.setItem("pageType", element.pageType);
setState({ loading: false });
- if (process.env.REACT_APP_ENABLE_SUBSCRIPTION) {
- navigate(`/subscription`, { replace: true });
+ if (isEnableSubscription) {
+ if (isFreeplan) {
+ navigate(
+ `/${element.pageType}/${element.pageId}`
+ );
+ } else {
+ navigate(`/subscription`, { replace: true });
+ }
} else {
navigate(
`/${element.pageType}/${element.pageId}`
@@ -626,7 +657,7 @@ const Signup = () => {
Login
@@ -661,4 +692,4 @@ const Signup = () => {
);
};
-export default Signup
+export default Signup;
diff --git a/apps/OpenSign/src/pages/SignyourselfPdf.js b/apps/OpenSign/src/pages/SignyourselfPdf.js
index 4538732f8..9cdef9b7a 100644
--- a/apps/OpenSign/src/pages/SignyourselfPdf.js
+++ b/apps/OpenSign/src/pages/SignyourselfPdf.js
@@ -99,6 +99,7 @@ function SignYourSelf() {
});
const [isAlert, setIsAlert] = useState({ isShow: false, alertMessage: "" });
const [isDontShow, setIsDontShow] = useState(false);
+ const [extUserId, setExtUserId] = useState("");
const divRef = useRef(null);
const nodeRef = useRef(null);
const [, drop] = useDrop({
@@ -186,7 +187,7 @@ function SignYourSelf() {
if (documentData && documentData.length > 0) {
setPdfDetails(documentData);
-
+ setExtUserId(documentData[0]?.ExtUserPtr?.objectId);
isCompleted = documentData[0].IsCompleted && documentData[0].IsCompleted;
if (isCompleted) {
const docStatus = {
@@ -433,13 +434,13 @@ function SignYourSelf() {
Width: widgetTypeExist
? calculateInitialWidthHeight(dragTypeValue, widgetValue).getWidth
: dragTypeValue === "initials"
- ? defaultWidthHeight(dragTypeValue).width
- : "",
+ ? defaultWidthHeight(dragTypeValue).width
+ : "",
Height: widgetTypeExist
? calculateInitialWidthHeight(dragTypeValue, widgetValue).getHeight
: dragTypeValue === "initials"
- ? defaultWidthHeight(dragTypeValue).height
- : "",
+ ? defaultWidthHeight(dragTypeValue).height
+ : "",
options: addWidgetOptions(dragTypeValue)
};
@@ -1120,6 +1121,7 @@ function SignYourSelf() {
setSuccessEmail={setSuccessEmail}
sender={jsonSender}
setIsAlert={setIsAlert}
+ extUserId={extUserId}
/>
{/* pdf header which contain funish back button */}
{
const navigate = useNavigate();
const { templateId } = useParams();
@@ -52,6 +53,7 @@ const TemplatePlaceholder = () => {
const [isSelectListId, setIsSelectId] = useState();
const [isSendAlert, setIsSendAlert] = useState(false);
const [isCreateDocModal, setIsCreateDocModal] = useState(false);
+ const [isSubscribe, setIsSubscribe] = useState(false);
const [isLoading, setIsLoading] = useState({
isLoad: true,
message: "This might take some time"
@@ -168,7 +170,26 @@ const TemplatePlaceholder = () => {
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [divRef.current]);
-
+ async function checkIsSubscribed(email) {
+ const user = await Parse.Cloud.run("getUserDetails", {
+ email: email
+ });
+ const freeplan = user?.get("Plan") && user?.get("Plan").plan_code;
+ const billingDate =
+ user?.get("Next_billing_date") && user?.get("Next_billing_date");
+ if (freeplan === "freeplan") {
+ return true;
+ } else if (billingDate) {
+ if (billingDate > new Date()) {
+ setIsSubscribe(true);
+ return true;
+ } else {
+ navigate(`/subscription`);
+ }
+ } else {
+ navigate(`/subscription`);
+ }
+ }
// `fetchTemplate` function in used to get Template from server and setPlaceholder ,setSigner if present
const fetchTemplate = async () => {
try {
@@ -190,6 +211,9 @@ const TemplatePlaceholder = () => {
: [];
if (documentData && documentData.length > 0) {
+ if (isEnableSubscription) {
+ checkIsSubscribed(documentData[0]?.ExtUserPtr?.Email);
+ }
setPdfDetails(documentData);
setIsSigners(true);
if (documentData[0].Signers && documentData[0].Signers.length > 0) {
@@ -1323,6 +1347,7 @@ const TemplatePlaceholder = () => {
currWidgetsDetails={currWidgetsDetails}
setCurrWidgetsDetails={setCurrWidgetsDetails}
handleClose={handleNameModal}
+ isSubscribe={isSubscribe}
/>
{
currWidgetsDetails={currWidgetsDetails}
setCurrWidgetsDetails={setCurrWidgetsDetails}
handleClose={handleNameModal}
+ isSubscribe={isSubscribe}
/>
{
currWidgetsDetails={currWidgetsDetails}
setCurrWidgetsDetails={setCurrWidgetsDetails}
handleClose={handleNameModal}
+ isSubscribe={isSubscribe}
/>
{
isOpen={isNameModal}
handleClose={handleNameModal}
handleData={handleWidgetdefaultdata}
+ isSubscribe={isSubscribe}
/>
);
diff --git a/apps/OpenSign/src/pages/UserProfile.js b/apps/OpenSign/src/pages/UserProfile.js
index b8d9da22c..7fd7163fb 100644
--- a/apps/OpenSign/src/pages/UserProfile.js
+++ b/apps/OpenSign/src/pages/UserProfile.js
@@ -8,6 +8,9 @@ import sanitizeFileName from "../primitives/sanitizeFileName";
import axios from "axios";
import PremiumAlertHeader from "../primitives/PremiumAlertHeader";
import Tooltip from "../primitives/Tooltip";
+import { isEnableSubscription } from "../constant/const";
+import { checkIsSubscribed } from "../constant/Utils";
+import Upgrade from "../primitives/Upgrade";
function UserProfile() {
const navigate = useNavigate();
@@ -21,15 +24,24 @@ function UserProfile() {
const [isLoader, setIsLoader] = useState(false);
const [percentage, setpercentage] = useState(0);
const [isDisableDocId, setIsDisableDocId] = useState(false);
+ const [isSubscribe, setIsSubscribe] = useState(false);
useEffect(() => {
+ getUserDetail();
+ }, []);
+
+ const getUserDetail = async () => {
const extClass = localStorage.getItem("Extand_Class");
const jsonSender = JSON.parse(extClass);
const HeaderDocId = jsonSender[0]?.HeaderDocId;
+ if (isEnableSubscription) {
+ const getIsSubscribe = await checkIsSubscribed();
+ setIsSubscribe(getIsSubscribe);
+ }
if (HeaderDocId) {
setIsDisableDocId(HeaderDocId);
}
- }, []);
+ };
const handleSubmit = async (e) => {
e.preventDefault();
setIsLoader(true);
@@ -137,7 +149,8 @@ function UserProfile() {
setImage(response.url());
localStorage.setItem("profileImg", response.url());
setpercentage(0);
- SaveFileSize(size, response.url());
+ const tenantId = localStorage.getItem("TenantId");
+ SaveFileSize(size, response.url(), tenantId);
return response.url();
}
} catch (error) {
@@ -155,7 +168,6 @@ function UserProfile() {
const handleDisableDocId = () => {
setIsDisableDocId((prevChecked) => !prevChecked);
};
-
return (
@@ -262,14 +274,30 @@ function UserProfile() {
-
+
Disable DocumentId :{" "}
- {" "}
+ {" "}
+ {!isSubscribe && isEnableSubscription && }
{" "}
diff --git a/apps/OpenSign/src/pages/Webhook.js b/apps/OpenSign/src/pages/Webhook.js
index fb7fe0616..c32e5b9d7 100644
--- a/apps/OpenSign/src/pages/Webhook.js
+++ b/apps/OpenSign/src/pages/Webhook.js
@@ -1,15 +1,17 @@
import React, { useEffect, useState } from "react";
import Title from "../components/Title";
import axios from "axios";
+import { useNavigate } from "react-router-dom";
import Alert from "../primitives/Alert";
import ModalUi from "../primitives/ModalUi";
-import { rejectBtn, submitBtn } from "../constant/const";
-import { openInNewTab } from "../constant/Utils";
+import { isEnableSubscription, rejectBtn, submitBtn } from "../constant/const";
+import { checkIsSubscribed, openInNewTab } from "../constant/Utils";
import Parse from "parse";
import PremiumAlertHeader from "../primitives/PremiumAlertHeader";
import Tooltip from "../primitives/Tooltip";
function Webhook() {
+ const navigation = useNavigate();
const [parseBaseUrl] = useState(localStorage.getItem("baseUrl"));
const [parseAppId] = useState(localStorage.getItem("parseAppId"));
const [webhook, setWebhook] = useState();
@@ -17,6 +19,8 @@ function Webhook() {
const [isGenerate, setIsGenerate] = useState(false);
const [isErr, setIsErr] = useState(false);
const [isModal, setIsModal] = useState(false);
+ const [isSubscribe, setIsSubscribe] = useState(false);
+ const [error, setError] = useState("");
useEffect(() => {
fetchWebhook();
@@ -25,6 +29,10 @@ function Webhook() {
const fetchWebhook = async () => {
const email = Parse.User.current().getEmail();
+ if (isEnableSubscription) {
+ const getIsSubscribe = await checkIsSubscribed();
+ setIsSubscribe(getIsSubscribe);
+ }
const params = { email: email };
try {
const extRes = await Parse.Cloud.run("getUserDetails", params);
@@ -40,41 +48,48 @@ function Webhook() {
};
const handleSubmit = async (e) => {
e.preventDefault();
- setIsLoader(true);
- setIsModal(false);
- try {
- const params = { url: webhook };
- const url = parseBaseUrl + "functions/savewebhook";
- const headers = {
- "Content-Type": "application/json",
- "X-Parse-Application-Id": parseAppId,
- sessiontoken: localStorage.getItem("accesstoken")
- };
- await axios.post(url, params, { headers: headers }).then((res) => {
- if (res.data && res.data.result && res.data.result.Webhook) {
- setWebhook(res.data.result.Webhook);
- setIsGenerate(true);
- setTimeout(() => {
- setIsGenerate(false);
- }, 1500);
- setIsLoader(false);
- } else {
- console.error("Error while generating webhook");
- setIsLoader(false);
- setIsErr(true);
- setTimeout(() => {
- setIsErr(false);
- }, 1500);
- }
- });
- } catch (error) {
- setIsLoader(false);
- setIsErr(true);
+ if (webhook && webhook.startsWith("https://")) {
+ setIsLoader(true);
+ setIsModal(false);
+ try {
+ const params = { url: webhook };
+ const url = parseBaseUrl + "functions/savewebhook";
+ const headers = {
+ "Content-Type": "application/json",
+ "X-Parse-Application-Id": parseAppId,
+ sessiontoken: localStorage.getItem("accesstoken")
+ };
+ await axios.post(url, params, { headers: headers }).then((res) => {
+ if (res.data && res.data.result && res.data.result.Webhook) {
+ setWebhook(res.data.result.Webhook);
+ setIsGenerate(true);
+ setTimeout(() => {
+ setIsGenerate(false);
+ }, 1500);
+ setIsLoader(false);
+ } else {
+ console.error("Error while generating webhook");
+ setIsLoader(false);
+ setIsErr(true);
+ setTimeout(() => {
+ setIsErr(false);
+ }, 1500);
+ }
+ });
+ } catch (error) {
+ setIsLoader(false);
+ setIsErr(true);
+ setTimeout(() => {
+ setIsErr(false);
+ }, 1500);
+
+ console.log("err", error);
+ }
+ } else {
+ setError("The webhook url should always start with https://");
setTimeout(() => {
- setIsErr(false);
+ setError("");
}, 1500);
-
- console.log("err", error);
}
};
@@ -84,6 +99,7 @@ function Webhook() {
{isGenerate &&
Webhook added successfully! }
{isErr &&
Something went wrong! }
+
{isLoader ? (
) : (
-
-
- Webhook{" "}
+ {!isEnableSubscription && }
+
+ OpenSign™ Webhook{" "}
-
+
-
-
- {webhook ? "Update Webhook" : "Add Webhook"}
-
+
+
@@ -135,17 +161,47 @@ function Webhook() {
"https://docs.opensignlabs.com/docs/API-docs/save-update-webhook"
)
}
- className="rounded hover:bg-[#15b4e9] border-[1px] border-[#15b4e9] text-[#15b4e9] hover:text-white px-11 py-2 text-xs md:text-base focus:outline-none"
+ className="rounded hover:bg-[#15b4e9] border-[1px] my-2 border-[#15b4e9] text-[#15b4e9] hover:text-white px-11 py-2 text-xs md:text-base focus:outline-none"
>
View Docs
+ {!isSubscribe && isEnableSubscription && (
+ <>
+
+ Upgrade to PRO Plan
+
+
+ >
+ )}
+ {error && {error} }
Webhook
diff --git a/apps/OpenSign/src/primitives/AddUser.js b/apps/OpenSign/src/primitives/AddUser.js
index 42ff14115..ee24e8ce0 100644
--- a/apps/OpenSign/src/primitives/AddUser.js
+++ b/apps/OpenSign/src/primitives/AddUser.js
@@ -54,11 +54,11 @@ const AddUser = (props) => {
contactQuery.set("Email", email);
contactQuery.set("UserRole", "contracts_Guest");
- if (localStorage.getItem("TenetId")) {
+ if (localStorage.getItem("TenantId")) {
contactQuery.set("TenantId", {
__type: "Pointer",
className: "partners_Tenant",
- objectId: localStorage.getItem("TenetId")
+ objectId: localStorage.getItem("TenantId")
});
}
diff --git a/apps/OpenSign/src/primitives/Tooltip.js b/apps/OpenSign/src/primitives/Tooltip.js
index b3fdc3e64..f49e4bce7 100644
--- a/apps/OpenSign/src/primitives/Tooltip.js
+++ b/apps/OpenSign/src/primitives/Tooltip.js
@@ -1,9 +1,17 @@
import React from "react";
import { Tooltip as ReactTooltip } from "react-tooltip";
import { openInNewTab } from "../constant/Utils";
-const Tooltip = ({ id, message, url, iconColor }) =>
+import { isEnableSubscription } from "../constant/const";
+const Tooltip = ({ id, message, url, iconColor, isSubscribe }) =>
url ? (
-
openInNewTab(url)} className="text-center">
+ openInNewTab(url)}
+ className={
+ isSubscribe || !isEnableSubscription
+ ? "text-center"
+ : "text-center opacity-20 pointer-events-none"
+ }
+ >
+ navigation("/subscription")}
+ className="text-blue-800 text-sm cursor-pointer hover:underline"
+ >
+ Upgrade now
+
+
+ );
+}
+
+export default Upgrade;
diff --git a/apps/OpenSign/src/primitives/Validate.js b/apps/OpenSign/src/primitives/Validate.js
index 86993d8b3..c2920b631 100644
--- a/apps/OpenSign/src/primitives/Validate.js
+++ b/apps/OpenSign/src/primitives/Validate.js
@@ -24,7 +24,9 @@ const Validate = () => {
setIsUserValid(false);
}
})();
+ // eslint-disable-next-line react-hooks/exhaustive-deps
}, []);
+
const handleLoginBtn = () => {
try {
Parse.User.logOut();
diff --git a/apps/OpenSignServer/Utils.js b/apps/OpenSignServer/Utils.js
index 8fc705ceb..d94b46118 100644
--- a/apps/OpenSignServer/Utils.js
+++ b/apps/OpenSignServer/Utils.js
@@ -1,3 +1,7 @@
+import axios from 'axios';
+
+const appId = process.env.APP_ID;
+const serverUrl = process.env.SERVER_URL;
export function customAPIurl() {
const url = new URL(process.env.SERVER_URL);
return url.pathname === '/api/app' ? url.origin + '/api' : url.origin;
@@ -38,3 +42,111 @@ export function replaceMailVaribles(subject, body, variables) {
};
return result;
}
+
+export const saveFileUsage = async (size, imageUrl, userId) => {
+ //checking server url and save file's size
+
+ try {
+ const tenantQuery = new Parse.Query('partners_Tenant');
+ tenantQuery.equalTo('UserId', {
+ __type: 'Pointer',
+ className: '_User',
+ objectId: userId,
+ });
+ const tenant = await tenantQuery.first();
+ if (tenant) {
+ const tenantPtr = {
+ __type: 'Pointer',
+ className: 'partners_Tenant',
+ objectId: tenant.id,
+ };
+ const _tenantPtr = JSON.stringify(tenantPtr);
+ try {
+ const res = await axios.get(
+ `${serverUrl}/classes/partners_TenantCredits?where={"PartnersTenant":${_tenantPtr}}`,
+ {
+ headers: {
+ 'Content-Type': 'application/json',
+ 'X-Parse-Application-Id': appId,
+ },
+ }
+ );
+ const response = res.data.results;
+
+ let data;
+ // console.log("response", response);
+ if (response && response.length > 0) {
+ data = {
+ usedStorage: response[0].usedStorage ? response[0].usedStorage + size : size,
+ };
+ await axios.put(
+ `${serverUrl}/classes/partners_TenantCredits/${response[0].objectId}`,
+ data,
+ {
+ headers: {
+ 'Content-Type': 'application/json',
+ 'X-Parse-Application-Id': appId,
+ },
+ }
+ );
+ } else {
+ data = { usedStorage: size, PartnersTenant: tenantPtr };
+ await axios.post(`${serverUrl}/classes/partners_TenantCredits`, data, {
+ headers: {
+ 'Content-Type': 'application/json',
+ 'X-Parse-Application-Id': appId,
+ },
+ });
+ }
+ } catch (err) {
+ console.log('err in save usage', err);
+ }
+ saveDataFile(size, imageUrl, tenantPtr);
+ }
+ } catch (err) {
+ console.log('err in fetch tenant Id', err);
+ }
+};
+
+//function for save fileUrl and file size in particular client db class partners_DataFiles
+const saveDataFile = async (size, imageUrl, tenantPtr) => {
+ const data = {
+ FileUrl: imageUrl,
+ FileSize: size,
+ TenantPtr: tenantPtr,
+ };
+
+ // console.log("data save",file, data)
+ try {
+ await axios.post(`${serverUrl}/classes/partners_DataFiles`, data, {
+ headers: {
+ 'Content-Type': 'application/json',
+ 'X-Parse-Application-Id': appId,
+ },
+ });
+ } catch (err) {
+ console.log('error in save usage ', err);
+ }
+};
+
+export const updateMailCount = async extUserId => {
+ // Update count in contracts_Users class
+ const query = new Parse.Query('contracts_Users');
+ query.equalTo('objectId', extUserId);
+
+ try {
+ const contractUser = await query.first({ useMasterKey: true });
+ if (contractUser) {
+ contractUser.increment('EmailCount', 1);
+ await contractUser.save(null, { useMasterKey: true });
+ } else {
+ // Create new entry if not found
+ const ContractsUsers = Parse.Object.extend('contracts_users');
+ const newContractUser = new ContractsUsers();
+ newContractUser.set('EmailCount', 1);
+ await newContractUser.save(null, { useMasterKey: true });
+ }
+ } catch (error) {
+ console.log('Error updating EmailCount in contracts_users: ' + error.message);
+ }
+};
diff --git a/apps/OpenSignServer/cloud/customRoute/v1/routes/CreateDocumentWithTemplate.js b/apps/OpenSignServer/cloud/customRoute/v1/routes/CreateDocumentWithTemplate.js
index 970c95b5f..b3b6f2179 100644
--- a/apps/OpenSignServer/cloud/customRoute/v1/routes/CreateDocumentWithTemplate.js
+++ b/apps/OpenSignServer/cloud/customRoute/v1/routes/CreateDocumentWithTemplate.js
@@ -284,6 +284,7 @@ export default async function createDocumentWithTemplate(request, response) {
subject: subject,
from: sender,
html: html,
+ extUserId: template.ExtUserPtr.objectId,
};
sendMail = await axios.post(url, params, { headers: headers });
} catch (error) {
diff --git a/apps/OpenSignServer/cloud/customRoute/v1/routes/createDocumentwithCoordinate.js b/apps/OpenSignServer/cloud/customRoute/v1/routes/createDocumentwithCoordinate.js
index ba7d7b22d..05477562e 100644
--- a/apps/OpenSignServer/cloud/customRoute/v1/routes/createDocumentwithCoordinate.js
+++ b/apps/OpenSignServer/cloud/customRoute/v1/routes/createDocumentwithCoordinate.js
@@ -1,5 +1,5 @@
import axios from 'axios';
-import { color, customAPIurl, replaceMailVaribles } from '../../../../Utils.js';
+import { color, customAPIurl, replaceMailVaribles, saveFileUsage } from '../../../../Utils.js';
// `sendDoctoWebhook` is used to send res data of document on webhook
async function sendDoctoWebhook(doc, WebhookUrl, userId) {
@@ -8,6 +8,7 @@ async function sendDoctoWebhook(doc, WebhookUrl, userId) {
event: 'created',
...doc,
};
+
await axios
.post(WebhookUrl, params, {
headers: { 'Content-Type': 'application/json' },
@@ -65,6 +66,7 @@ export default async function createDocumentwithCoordinate(request, response) {
if (!reqToken) {
return response.status(400).json({ error: 'Please Provide API Token' });
}
+
try {
const tokenQuery = new Parse.Query('appToken');
tokenQuery.equalTo('token', reqToken);
@@ -81,17 +83,22 @@ export default async function createDocumentwithCoordinate(request, response) {
if (signers && signers.length > 0) {
let fileUrl;
if (request.files?.[0]) {
+ const base64 = fileData?.toString('base64');
const file = new Parse.File(request.files?.[0]?.originalname, {
- base64: fileData?.toString('base64'),
+ base64: base64,
});
await file.save({ useMasterKey: true });
fileUrl = file.url();
+ const buffer = Buffer.from(base64, 'base64');
+ saveFileUsage(buffer.length, fileUrl, parseUser.userId.objectId);
} else {
const file = new Parse.File(`${name}.pdf`, {
base64: base64File,
});
await file.save({ useMasterKey: true });
fileUrl = file.url();
+ const buffer = Buffer.from(base64File, 'base64');
+ saveFileUsage(buffer.length, fileUrl, parseUser.userId.objectId);
}
const contractsUser = new Parse.Query('contracts_Users');
contractsUser.equalTo('UserId', userPtr);
@@ -242,7 +249,6 @@ export default async function createDocumentwithCoordinate(request, response) {
year: 'numeric',
});
let sender = parseExtUser.Email;
- let sendMail;
const serverUrl = process.env.SERVER_URL;
const newServer = serverUrl.replaceAll('/', '%2F');
const serverParams = `${newServer}%2F&${process.env.APP_ID}&contracts`;
@@ -330,9 +336,10 @@ export default async function createDocumentwithCoordinate(request, response) {
subject: subject,
from: sender,
html: html,
+ extUserId: extUser.id,
};
- sendMail = await axios.post(url, params, { headers: headers });
+ await axios.post(url, params, { headers: headers });
} catch (error) {
console.log('error', error);
}
diff --git a/apps/OpenSignServer/cloud/customRoute/v1/routes/createTemplate.js b/apps/OpenSignServer/cloud/customRoute/v1/routes/createTemplate.js
index 2219dc2df..a0874f1e0 100644
--- a/apps/OpenSignServer/cloud/customRoute/v1/routes/createTemplate.js
+++ b/apps/OpenSignServer/cloud/customRoute/v1/routes/createTemplate.js
@@ -1,6 +1,4 @@
-import { customAPIurl } from '../../../../Utils.js';
-
-const randomId = () => Math.floor(1000 + Math.random() * 9000);
+import { saveFileUsage } from '../../../../Utils.js';
export default async function createTemplate(request, response) {
const name = request.body?.title;
const note = request.body?.note;
@@ -36,12 +34,17 @@ export default async function createTemplate(request, response) {
});
await file.save({ useMasterKey: true });
fileUrl = file.url();
+ const buffer = Buffer.from(base64File, 'base64');
+ saveFileUsage(buffer.length, fileUrl, parseUser.userId.objectId);
} else {
+ const base64 = fileData?.toString('base64');
const file = new Parse.File(request.files?.[0]?.originalname, {
- base64: fileData?.toString('base64'),
+ base64: base64,
});
await file.save({ useMasterKey: true });
fileUrl = file.url();
+ const buffer = Buffer.from(base64, 'base64');
+ saveFileUsage(buffer.length, fileUrl, parseUser.userId.objectId);
}
const contractsUser = new Parse.Query('contracts_Users');
diff --git a/apps/OpenSignServer/cloud/customRoute/v1/routes/createTemplatewithCoordinate.js b/apps/OpenSignServer/cloud/customRoute/v1/routes/createTemplatewithCoordinate.js
index b2a4d2aef..28203575e 100644
--- a/apps/OpenSignServer/cloud/customRoute/v1/routes/createTemplatewithCoordinate.js
+++ b/apps/OpenSignServer/cloud/customRoute/v1/routes/createTemplatewithCoordinate.js
@@ -1,5 +1,5 @@
import axios from 'axios';
-import { color, customAPIurl } from '../../../../Utils.js';
+import { color, customAPIurl, saveFileUsage } from '../../../../Utils.js';
const randomId = () => Math.floor(1000 + Math.random() * 9000);
export default async function createTemplatewithCoordinate(request, response) {
@@ -34,17 +34,22 @@ export default async function createTemplatewithCoordinate(request, response) {
if (signers && signers.length > 0) {
let fileUrl;
if (request.files?.[0]) {
+ const base64 = fileData?.toString('base64');
const file = new Parse.File(request.files?.[0]?.originalname, {
- base64: fileData?.toString('base64'),
+ base64: base64,
});
await file.save({ useMasterKey: true });
fileUrl = file.url();
+ const buffer = Buffer.from(base64, 'base64');
+ saveFileUsage(buffer.length, fileUrl, parseUser.userId.objectId);
} else {
const file = new Parse.File(`${name}.pdf`, {
base64: base64File,
});
await file.save({ useMasterKey: true });
fileUrl = file.url();
+ const buffer = Buffer.from(base64File, 'base64');
+ saveFileUsage(buffer.length, fileUrl, parseUser.userId.objectId);
}
const contractsUser = new Parse.Query('contracts_Users');
contractsUser.equalTo('UserId', userPtr);
diff --git a/apps/OpenSignServer/cloud/customRoute/v1/routes/draftDocument.js b/apps/OpenSignServer/cloud/customRoute/v1/routes/draftDocument.js
index 3dda24f5d..7f31b66bc 100644
--- a/apps/OpenSignServer/cloud/customRoute/v1/routes/draftDocument.js
+++ b/apps/OpenSignServer/cloud/customRoute/v1/routes/draftDocument.js
@@ -36,17 +36,22 @@ export default async function draftDocument(request, response) {
if (signers && signers.length > 0) {
let fileUrl;
if (request.files?.[0]) {
+ const base64 = fileData?.toString('base64');
const file = new Parse.File(request.files?.[0]?.originalname, {
- base64: fileData?.toString('base64'),
+ base64: base64,
});
await file.save({ useMasterKey: true });
fileUrl = file.url();
+ const buffer = Buffer.from(base64, 'base64');
+ saveFileUsage(buffer.length, fileUrl, parseUser.userId.objectId);
} else {
const file = new Parse.File(`${name}.pdf`, {
base64: base64File,
});
await file.save({ useMasterKey: true });
fileUrl = file.url();
+ const buffer = Buffer.from(base64File, 'base64');
+ saveFileUsage(buffer.length, fileUrl, parseUser.userId.objectId);
}
const contractsUser = new Parse.Query('contracts_Users');
contractsUser.equalTo('UserId', userPtr);
diff --git a/apps/OpenSignServer/cloud/main.js b/apps/OpenSignServer/cloud/main.js
index d0838e72f..7850e9b56 100644
--- a/apps/OpenSignServer/cloud/main.js
+++ b/apps/OpenSignServer/cloud/main.js
@@ -1,5 +1,5 @@
import PDF from './parsefunction/pdf/PDF.min.js';
-import sendmail from './parsefunction/sendMail.js';
+import sendmailv3 from './parsefunction/sendMailv3.js';
import GoogleSign from './parsefunction/GoogleSign.js';
import ZohoDetails from './parsefunction/ZohoDetails.js';
import usersignup from './parsefunction/usersignup.js';
@@ -10,7 +10,6 @@ import DocumentAftersave from './parsefunction/DocumentAftersave.js';
import ContactbookAftersave from './parsefunction/ContactBookAftersave.js';
import ContractUsersAftersave from './parsefunction/ContractUsersAftersave.js';
import sendMailOTPv1 from './parsefunction/SendMailOTPv1.js';
-import SendMailv1 from './parsefunction/SendMailv1.js';
import AuthLoginAsMail from './parsefunction/AuthLoginAsMail.js';
import getUserId from './parsefunction/getUserId.js';
import getUserDetails from './parsefunction/getUserDetails.js';
@@ -23,17 +22,19 @@ import TemplateAfterSave from './parsefunction/TemplateAfterSave.js';
import GetTemplate from './parsefunction/GetTemplate.js';
import savewebhook from './parsefunction/saveWebhook.js';
import callWebhook from './parsefunction/callWebhook.js';
+import SubscribeFree from './parsefunction/SubscribeFree.js';
+import DocumentBeforesave from './parsefunction/DocumentBeforesave.js';
+import TemplateBeforeSave from './parsefunction/TemplateBeforesave.js';
Parse.Cloud.define('AddUserToRole', addUserToGroups);
Parse.Cloud.define('UserGroups', getUserGroups);
Parse.Cloud.define('signPdf', PDF);
-Parse.Cloud.define('sendmailv3', sendmail);
+Parse.Cloud.define('sendmailv3', sendmailv3);
Parse.Cloud.define('googlesign', GoogleSign);
Parse.Cloud.define('zohodetails', ZohoDetails);
Parse.Cloud.define('usersignup', usersignup);
Parse.Cloud.define('facebooksign', FacebookSign);
Parse.Cloud.define('SendOTPMailV1', sendMailOTPv1);
-Parse.Cloud.define('sendmail', SendMailv1);
Parse.Cloud.define('AuthLoginAsMail', AuthLoginAsMail);
Parse.Cloud.define('getUserId', getUserId);
Parse.Cloud.define('getUserDetails', getUserDetails);
@@ -45,7 +46,10 @@ Parse.Cloud.define('getapitoken', getapitoken);
Parse.Cloud.define('getTemplate', GetTemplate);
Parse.Cloud.define('savewebhook', savewebhook);
Parse.Cloud.define('callwebhook', callWebhook);
+Parse.Cloud.define('freesubscription', SubscribeFree);
Parse.Cloud.afterSave('contracts_Document', DocumentAftersave);
Parse.Cloud.afterSave('contracts_Contactbook', ContactbookAftersave);
Parse.Cloud.afterSave('contracts_Users', ContractUsersAftersave);
Parse.Cloud.afterSave('contracts_Template', TemplateAfterSave);
+Parse.Cloud.beforeSave('contracts_Document', DocumentBeforesave);
+Parse.Cloud.beforeSave('contracts_Template', TemplateBeforeSave);
diff --git a/apps/OpenSignServer/cloud/parsefunction/DocumentBeforesave.js b/apps/OpenSignServer/cloud/parsefunction/DocumentBeforesave.js
new file mode 100644
index 000000000..14358e098
--- /dev/null
+++ b/apps/OpenSignServer/cloud/parsefunction/DocumentBeforesave.js
@@ -0,0 +1,35 @@
+async function DocumentBeforesave(request) {
+ try {
+ // below code is used to update document when user sent document or self signed
+ const document = request.object;
+ const oldDocument = request.original;
+
+ // Check if SignedUrl field has been added (transition from undefined to defined)
+ if (!oldDocument.get('SignedUrl') && document.get('SignedUrl')) {
+ const SignedUrl = document.get('SignedUrl');
+
+ // Update count in contracts_Users class
+ const query = new Parse.Query('contracts_Users');
+ query.equalTo('objectId', oldDocument.get('ExtUserPtr').id);
+
+ try {
+ const contractUser = await query.first({ useMasterKey: true });
+ if (contractUser) {
+ contractUser.increment('DocumentCount', 1);
+ await contractUser.save(null, { useMasterKey: true });
+ } else {
+ // Create new entry if not found
+ const ContractsUsers = Parse.Object.extend('contracts_users');
+ const newContractUser = new ContractsUsers();
+ newContractUser.set('DocumentCount', 1);
+ await newContractUser.save(null, { useMasterKey: true });
+ }
+ } catch (error) {
+ console.log('Error updating document count in contracts_users: ' + error.message);
+ }
+ }
+ } catch (err) {
+ console.log('err in document beforesave', err.message);
+ }
+}
+export default DocumentBeforesave;
diff --git a/apps/OpenSignServer/cloud/parsefunction/SendMailOTPv1.js b/apps/OpenSignServer/cloud/parsefunction/SendMailOTPv1.js
index 4c3b52283..290ff0c3a 100644
--- a/apps/OpenSignServer/cloud/parsefunction/SendMailOTPv1.js
+++ b/apps/OpenSignServer/cloud/parsefunction/SendMailOTPv1.js
@@ -1,47 +1,65 @@
-import axios from 'axios'
-
+import { updateMailCount } from '../../Utils.js';
+async function getDocument(docId) {
+ try {
+ const query = new Parse.Query('contracts_Document');
+ query.equalTo('objectId', docId);
+ query.include('ExtUserPtr');
+ query.include('CreatedBy');
+ query.include('Signers');
+ query.include('AuditTrail.UserPtr');
+ query.include('Placeholders');
+ query.notEqualTo('IsArchive', true);
+ const res = await query.first({ useMasterKey: true });
+ const _res = res.toJSON();
+ return _res?.ExtUserPtr?.objectId;
+ } catch (err) {
+ console.log('err ', err);
+ }
+}
async function sendMailOTPv1(request) {
try {
//--for elearning app side
let code = Math.floor(1000 + Math.random() * 9000);
let email = request.params.email;
var TenantId = request.params.TenantId ? request.params.TenantId : undefined;
- // console.log("In tempSendOTPv2");
-
- // console.log(JSON.stringify(request));
if (email) {
- axios({
- method: 'POST',
- url: process.env.SERVER_URL + '/functions/sendmail',
- headers: {
- 'Content-Type': 'application/json',
- 'X-Parse-Application-Id': process.env.APP_ID,
- },
- params: {
- otp: code,
- email: email,
- TenantId: TenantId,
- },
- }).then(
- function (httpResponse) {},
- function (httpResponse) {
- console.error('sms Request failed with response code ' + httpResponse.status);
- return Promise.reject('sms Request failed with response code ' + httpResponse.status);
+ const recipient = request.params.email;
+ const mailsender = process.env.SMTP_ENABLE
+ ? process.env.SMTP_USER_EMAIL
+ : process.env.MAILGUN_SENDER;
+ try {
+ await Parse.Cloud.sendEmail({
+ from: 'Opensign™' + ' <' + mailsender + '>',
+ recipient: recipient,
+ subject: 'Your OpenSign™ OTP',
+ text: 'This email is a test.',
+ html:
+ "Your OTP for OpenSign™ verification is:
" +
+ code +
+ '
',
+ });
+ console.log('OTP sent');
+ if (request.params?.docId) {
+ const extUserId = await getDocument(request.params?.docId);
+ if (extUserId) {
+ updateMailCount(extUserId);
+ }
}
- );
-
+ } catch (err) {
+ console.log('error in send OTP mail', err);
+ }
const tempOtp = new Parse.Query('defaultdata_Otp');
tempOtp.equalTo('Email', email);
const resultOTP = await tempOtp.first({ useMasterKey: true });
- console.log('resultOTP', resultOTP);
+ // console.log('resultOTP', resultOTP);
if (resultOTP !== undefined) {
const updateOtpQuery = new Parse.Query('defaultdata_Otp');
const updateOtp = await updateOtpQuery.get(resultOTP.id, {
useMasterKey: true,
});
updateOtp.set('OTP', code);
- const updateRes = updateOtp.save(null, { useMasterKey: true });
+ updateOtp.save(null, { useMasterKey: true });
// console.log("update otp Res in tempSendOtp ", updateRes);
} else {
const otpClass = Parse.Object.extend('defaultdata_Otp');
@@ -49,17 +67,17 @@ async function sendMailOTPv1(request) {
newOtpQuery.set('OTP', code);
newOtpQuery.set('Email', email);
newOtpQuery.set('TenantId', TenantId);
- const newRes = await newOtpQuery.save(null, { useMasterKey: true });
+ await newOtpQuery.save(null, { useMasterKey: true });
// console.log("new otp Res in tempSendOtp ", newRes);
}
return 'Otp send';
} else {
- return Promise.reject('Please Enter valid email');
+ return 'Please Enter valid email';
}
} catch (err) {
console.log('err in sendMailOTPv1');
console.log(err);
- return Promise.reject(err);
+ return err;
}
}
export default sendMailOTPv1;
diff --git a/apps/OpenSignServer/cloud/parsefunction/SendMailv1.js b/apps/OpenSignServer/cloud/parsefunction/SendMailv1.js
deleted file mode 100644
index 741ac4ec0..000000000
--- a/apps/OpenSignServer/cloud/parsefunction/SendMailv1.js
+++ /dev/null
@@ -1,27 +0,0 @@
-async function SendMailv1(request) {
- console.log('in SendMailv1');
-
- try {
- const recipient = request.params.email;
- const otp = request.params.otp;
- const res = await Parse.Cloud.sendEmail({
- from: 'Test user' + ' <' + process.env.SMTP_ENABLE ? process.env.SMTP_USER_EMAIL : process.env.MAILGUN_SENDER + '>',
- recipient: recipient,
- subject: 'Your OpenSign™ OTP',
- text: 'This email is a test.',
- html:
- "Your OTP for OpenSign™ verification is:
" +
- otp +
- '
',
- // " Hello,
Your OTP for LegaDaft verification . 76984
Thank You! "
- });
- console.log('Res');
- console.log(res);
- return otp;
- } catch (err) {
- console.log('err in SendMailv1');
- console.log(err);
- return err;
- }
-}
-export default SendMailv1;
diff --git a/apps/OpenSignServer/cloud/parsefunction/SubscribeFree.js b/apps/OpenSignServer/cloud/parsefunction/SubscribeFree.js
new file mode 100644
index 000000000..03c4fb95f
--- /dev/null
+++ b/apps/OpenSignServer/cloud/parsefunction/SubscribeFree.js
@@ -0,0 +1,43 @@
+export default async function SubscribeFree(request) {
+ const userId = request.params.userId;
+ const userPtr = { __type: 'Pointer', className: '_User', objectId: userId };
+ try {
+ const extQuery = new Parse.Query('contracts_Users');
+ extQuery.equalTo('UserId', userPtr);
+ const extUser = await extQuery.first({ useMasterKey: true });
+ if (extUser) {
+ if (extUser?.get('Plan')?.plan_code === 'freeplan') {
+ return { status: 'success', result: 'already subscribed!' };
+ } else if (extUser?.get('Next_billing_date') < new Date()) {
+ try {
+ const extUpdate = new Parse.Object('contracts_Users');
+ extUpdate.id = extUser.id;
+ extUpdate.set('Plan', { plan_code: 'freeplan' });
+ await extUpdate.save(null, { useMasterKey: true });
+ return { status: 'success', result: 'subscribed!' };
+ } catch (err) {
+ console.log('err ', err);
+ return { status: 'error', result: err.message };
+ }
+ } else if (extUser?.get('Next_billing_date') > new Date()) {
+ return { status: 'success', result: 'already subscribed!' };
+ } else {
+ try {
+ const extUpdate = new Parse.Object('contracts_Users');
+ extUpdate.id = extUser.id;
+ extUpdate.set('Plan', { plan_code: 'freeplan' });
+ await extUpdate.save(null, { useMasterKey: true });
+ return { status: 'success', result: 'subscribed!' };
+ } catch (err) {
+ console.log('err ', err);
+ return { status: 'error', result: err.message };
+ }
+ }
+ } else {
+ return { status: 'error', result: 'User not found!' };
+ }
+ } catch (err) {
+ console.log('err ', err);
+ return { status: 'error', result: err.message };
+ }
+}
diff --git a/apps/OpenSignServer/cloud/parsefunction/TemplateBeforesave.js b/apps/OpenSignServer/cloud/parsefunction/TemplateBeforesave.js
new file mode 100644
index 000000000..b2ba6e3d3
--- /dev/null
+++ b/apps/OpenSignServer/cloud/parsefunction/TemplateBeforesave.js
@@ -0,0 +1,31 @@
+async function TemplateBeforeSave(request) {
+ try {
+ if (!request.original) {
+ // below code is used to update template when user sent template or self signed
+ const template = request.object;
+
+ // Update count in contracts_Users class
+ const query = new Parse.Query('contracts_Users');
+ query.equalTo('objectId', template.get('ExtUserPtr').id);
+
+ try {
+ const contractUser = await query.first({ useMasterKey: true });
+ if (contractUser) {
+ contractUser.increment('TemplateCount', 1);
+ await contractUser.save(null, { useMasterKey: true });
+ } else {
+ // Create new entry if not found
+ const ContractsUsers = Parse.Object.extend('contracts_users');
+ const newContractUser = new ContractsUsers();
+ newContractUser.set('TemplateCount', 1);
+ await newContractUser.save(null, { useMasterKey: true });
+ }
+ } catch (error) {
+ console.log('Error updating template count in contracts_users: ' + error.message);
+ }
+ }
+ } catch (err) {
+ console.log('err in template beforesave', err.message);
+ }
+}
+export default TemplateBeforeSave;
diff --git a/apps/OpenSignServer/cloud/parsefunction/pdf/PDF.min.js b/apps/OpenSignServer/cloud/parsefunction/pdf/PDF.min.js
index 166f4449e..fe1463137 100644
--- a/apps/OpenSignServer/cloud/parsefunction/pdf/PDF.min.js
+++ b/apps/OpenSignServer/cloud/parsefunction/pdf/PDF.min.js
@@ -3,6 +3,7 @@ import fs from 'node:fs';
import axios from 'axios';
import { pdflibAddPlaceholder } from './customSignPdf/pdflibplaceholder.min.js';
import { PDFDocument } from 'pdf-lib';
+import { saveFileUsage } from '../../../Utils.js';
const serverUrl = process.env.SERVER_URL,
APPID = process.env.APP_ID,
masterKEY = process.env.MASTER_KEY;
@@ -16,20 +17,20 @@ async function uploadFile(e, a) {
console.log('Err ', e), fs.unlinkSync(a);
}
}
-async function updateDoc(t, s, r, i, o, n) {
+async function updateDoc(t, s, r, o, i, n) {
try {
var d = {
UserPtr: { __type: 'Pointer', className: n, objectId: r },
SignedUrl: s,
Activity: 'Signed',
- ipAddress: i,
+ ipAddress: o,
};
let e;
- var l = (e = o.AuditTrail && 0 < o.AuditTrail.length ? [...o.AuditTrail, d] : [d]).filter(
+ var l = (e = i.AuditTrail && 0 < i.AuditTrail.length ? [...i.AuditTrail, d] : [d]).filter(
e => 'Signed' === e.Activity
);
let a = !1;
- !((o.Signers && 0 < o.Signers.length && l.length !== o.Signers.length) || !(a = !0));
+ !((i.Signers && 0 < i.Signers.length && l.length !== i.Signers.length) || !(a = !0));
var c = { SignedUrl: s, AuditTrail: e, IsCompleted: a };
await axios.put(serverUrl + '/classes/contracts_Document/' + t, c, {
headers: {
@@ -43,39 +44,16 @@ async function updateDoc(t, s, r, i, o, n) {
return console.log('update doc err ', e), 'err';
}
}
-async function sendMail(e) {
- var a = e.url,
- t = e.sender,
- s = e.pdfName,
- a = {
- url: a,
- from: 'OpenSign™',
- recipient: e.receiver,
- subject: 'You have signed the doc - ' + s,
- pdfName: s,
- html:
- " A copy of the document " +
- s +
- ' Standard is attached to this email. Kindly download the document from the attachment.
This is an automated email from OpenSign™. For any queries regarding this email, please contact the sender ' +
- t.Mail +
- ' directly. If you think this email is inappropriate or spam, you may file a complaint with OpenSign™ here .
',
- };
- await axios.post(serverUrl + '/functions/sendmailv3', a, {
- headers: {
- 'Content-Type': 'application/json',
- 'X-Parse-Application-Id': APPID,
- 'X-Parse-Master-Key': masterKEY,
- },
- });
-}
async function sendCompletedMail(e) {
var a = e.url,
t = e.sender,
s = e.pdfName,
- a = {
+ r = e.receiver,
+ e = {
+ extUserId: e.extUserId,
url: a,
from: 'OpenSign™',
- recipient: e.receiver,
+ recipient: r,
subject: `Document ${s} has been signed by all parties`,
pdfName: s,
html:
@@ -85,7 +63,7 @@ async function sendCompletedMail(e) {
t.Mail +
' directly. If you think this email is inappropriate or spam, you may file a complaint with OpenSign™ here . ',
};
- await axios.post(serverUrl + '/functions/sendmailv3', a, {
+ await axios.post(serverUrl + '/functions/sendmailv3', e, {
headers: {
'Content-Type': 'application/json',
'X-Parse-Application-Id': APPID,
@@ -155,7 +133,7 @@ async function PDF(i) {
try {
var e = i.params.docId,
a = i.params.userId,
- o = await axios.get(
+ n = await axios.get(
serverUrl + '/classes/contracts_Document/' + e + '?include=ExtUserPtr,Signers',
{
headers: {
@@ -165,142 +143,137 @@ async function PDF(i) {
},
}
),
- t = await axios.get(serverUrl + '/users/me', {
+ d = await axios.get(serverUrl + '/users/me', {
headers: {
'X-Parse-Application-Id': APPID,
'X-Parse-Session-Token': i.headers.sessiontoken,
},
});
- if (!t.data || !t.data.objectId) return { status: 'error', message: 'this user not allowed!' };
+ if (!d.data || !d.data.objectId) return { status: 'error', message: 'This user not allowed!' };
{
- var n,
- d,
+ var t,
+ s,
l,
c = JSON.stringify({ objectId: a });
- let s, r;
- r = a
- ? (n = await axios.get(serverUrl + '/classes/contracts_Contactbook?where=' + c, {
+ let r, o;
+ o = a
+ ? (t = await axios.get(serverUrl + '/classes/contracts_Contactbook?where=' + c, {
headers: {
'X-Parse-Application-Id': APPID,
'X-Parse-Session-Token': i.headers.sessiontoken,
},
- })).data && 0 < n.data.results.length
- ? ((s = n), 'contracts_Contactbook')
- : ((s = await axios.get(serverUrl + '/classes/contracts_Users?where=' + c, {
+ })).data && 0 < t.data.results.length
+ ? ((r = t), 'contracts_Contactbook')
+ : ((r = await axios.get(serverUrl + '/classes/contracts_Users?where=' + c, {
headers: { 'X-Parse-Application-Id': APPID, 'X-Parse-Master-Key': masterKEY },
})),
'contracts_Users')
- : ((d = JSON.stringify({
- UserId: { __type: 'Pointer', className: '_User', objectId: t.data.objectId },
+ : ((s = JSON.stringify({
+ UserId: { __type: 'Pointer', className: '_User', objectId: d.data.objectId },
})),
- (l = await axios.get(serverUrl + '/classes/contracts_Users?where=' + d, {
+ (l = await axios.get(serverUrl + '/classes/contracts_Users?where=' + s, {
headers: { 'X-Parse-Application-Id': APPID, 'X-Parse-Master-Key': masterKEY },
})).data && 0 < l.data.results.length
- ? ((s = l), 'contracts_Users')
- : ((s = await axios.get(serverUrl + '/classes/contracts_Contactbook?where=' + d, {
+ ? ((r = l), 'contracts_Users')
+ : ((r = await axios.get(serverUrl + '/classes/contracts_Contactbook?where=' + s, {
headers: {
'X-Parse-Application-Id': APPID,
'X-Parse-Session-Token': i.headers.sessiontoken,
},
})),
'contracts_Contactbook'));
- var p = s.data.results[0].Name,
- m = s.data.results[0].Email;
+ var p = r.data.results[0].Name,
+ m = r.data.results[0].Email;
if (!i.params.pdfFile) return { status: 'error', message: 'pdf file not present!' };
{
let e = Buffer.from(i.params.pdfFile, 'base64');
var g = process.env.PFX_BASE64,
- h = Buffer.from(g, 'base64'),
- u = {
- UserPtr: { __type: 'Pointer', className: r, objectId: s.data.results[0].objectId },
+ u = Buffer.from(g, 'base64'),
+ h = {
+ UserPtr: { __type: 'Pointer', className: o, objectId: r.data.results[0].objectId },
SignedUrl: '',
Activity: 'Signed',
ipAddress: i.headers['x-real-ip'],
};
let a;
var f = (a =
- o.data.AuditTrail && 0 < o.data.AuditTrail.length
- ? [...o.data.AuditTrail, u]
- : [u]).filter(e => 'Signed' === e.Activity);
+ n.data.AuditTrail && 0 < n.data.AuditTrail.length
+ ? [...n.data.AuditTrail, h]
+ : [h]).filter(e => 'Signed' === e.Activity);
let t = !1;
!(
- (o.data.Signers && 0 < o.data.Signers.length && f.length !== o.data.Signers.length) ||
+ (n.data.Signers && 0 < n.data.Signers.length && f.length !== n.data.Signers.length) ||
!(t = !0)
);
- var y,
- P,
+ var P,
+ y,
v,
- b,
- x,
- w,
U,
+ b,
I,
- S,
- A = `exported_file_${Math.floor(5e3 * Math.random())}.pdf`,
- D = './exports/' + A,
- E =
- (t
- ? ((y = o.data.Signers?.map(e => e.Name + ' <' + e.Email + '>')),
- (e =
- y && 0 < y.length
- ? ((P = await PDFDocument.load(e)),
- pdflibAddPlaceholder({
- pdfDoc: P,
- reason: 'Digitally signed by OpenSign for ' + y?.join(', '),
- location: 'location',
- signatureLength: 15e3,
- }),
- (v = await P.save()),
- Buffer.from(v))
- : ((b = await PDFDocument.load(e)),
- pdflibAddPlaceholder({
- pdfDoc: b,
- reason: 'Digitally signed by OpenSign for ' + p + ' <' + m + '>',
- location: 'location',
- signatureLength: 15e3,
- }),
- (x = await b.save()),
- Buffer.from(x))),
- (w = await new SignPDF(e, h).signPDF()),
- fs.writeFileSync(D, w))
- : fs.writeFileSync(D, e),
- await uploadFile(A, D));
- if (E && E.imageUrl)
+ S = `exported_file_${Math.floor(5e3 * Math.random())}.pdf`,
+ x = './exports/' + S;
+ let s = e.length;
+ s = (
+ t
+ ? ((P = n.data.Signers?.map(e => e.Name + ' <' + e.Email + '>')),
+ (e =
+ P && 0 < P.length
+ ? ((y = await PDFDocument.load(e)),
+ pdflibAddPlaceholder({
+ pdfDoc: y,
+ reason: 'Digitally signed by OpenSign for ' + P?.join(', '),
+ location: 'location',
+ signatureLength: 15e3,
+ }),
+ (v = await y.save()),
+ Buffer.from(v))
+ : ((U = await PDFDocument.load(e)),
+ pdflibAddPlaceholder({
+ pdfDoc: U,
+ reason: 'Digitally signed by OpenSign for ' + p + ' <' + m + '>',
+ location: 'location',
+ signatureLength: 15e3,
+ }),
+ (b = await U.save()),
+ Buffer.from(b))),
+ (I = await new SignPDF(e, u).signPDF()),
+ fs.writeFileSync(x, I),
+ I)
+ : (fs.writeFileSync(x, e), e)
+ ).length;
+ var A,
+ w,
+ D = await uploadFile(S, x);
+ if (D && D.imageUrl)
return (
- (U = await updateDoc(
+ (A = await updateDoc(
i.params.docId,
- E.imageUrl,
- s.data.results[0].objectId,
+ D.imageUrl,
+ r.data.results[0].objectId,
i.headers['x-real-ip'],
- o.data,
- r
+ n.data,
+ o
)),
- (I = {
- url: E.imageUrl,
- sender: { Mail: o.data.ExtUserPtr.Email, Name: o.data.ExtUserPtr.Name },
- pdfName: o.data.Name,
- receiver: m,
- }),
- o.data.IsSendMail && !1 === o.data.IsSendMail
- ? console.log("don't send mail")
- : sendMail(I),
- sendDoctoWebhook(o, E.imageUrl, 'signed', s?.data.results?.[0]),
- U &&
- U.isCompleted &&
- ((S = {
- url: E.imageUrl,
- sender: { Mail: o.data.ExtUserPtr.Email, Name: 'OpenSign™' },
- pdfName: o.data.Name,
- receiver: o.data.ExtUserPtr.Email,
+ sendDoctoWebhook(n, D.imageUrl, 'signed', r?.data.results?.[0]),
+ saveFileUsage(s, D.imageUrl, d.data.objectId),
+ A &&
+ A.isCompleted &&
+ ((w = {
+ url: D.imageUrl,
+ sender: { Mail: n.data.ExtUserPtr.Email, Name: 'OpenSign™' },
+ pdfName: n.data.Name,
+ receiver: n.data.ExtUserPtr.Email,
+ extUserId: n.data.ExtUserPtr.objectId,
}),
- o.data.IsSendMail && !1 === o.data.IsSendMail
+ n.data.IsSendMail && !1 === n.data.IsSendMail
? console.log("don't send mail")
- : sendCompletedMail(S),
- sendDoctoWebhook(o, E.imageUrl, 'completed')),
- fs.unlinkSync(D),
- console.log('New Signed PDF created called: ' + D),
- 'success' === U.message
- ? { status: 'success', data: E.imageUrl }
+ : sendCompletedMail(w),
+ sendDoctoWebhook(n, D.imageUrl, 'completed')),
+ fs.unlinkSync(x),
+ console.log('New Signed PDF created called: ' + x),
+ 'success' === A.message
+ ? { status: 'success', data: D.imageUrl }
: { status: 'error', message: 'please provide required parameters!' }
);
}
diff --git a/apps/OpenSignServer/cloud/parsefunction/sendMail.js b/apps/OpenSignServer/cloud/parsefunction/sendMailv3.js
similarity index 88%
rename from apps/OpenSignServer/cloud/parsefunction/sendMail.js
rename to apps/OpenSignServer/cloud/parsefunction/sendMailv3.js
index f8fb5f8da..dd5844e61 100644
--- a/apps/OpenSignServer/cloud/parsefunction/sendMail.js
+++ b/apps/OpenSignServer/cloud/parsefunction/sendMailv3.js
@@ -3,8 +3,9 @@ import https from 'https';
import formData from 'form-data';
import Mailgun from 'mailgun.js';
import { createTransport } from 'nodemailer';
+import { updateMailCount } from '../../Utils.js';
-async function sendmail(req) {
+async function sendmailv3(req) {
try {
let transporterSMTP;
let mailgunClient;
@@ -77,6 +78,9 @@ async function sendmail(req) {
const res = await transporterSMTP.sendMail(messageParams);
console.log('Res ', res);
if (!res.err) {
+ if (req.params?.extUserId) {
+ await updateMailCount(req.params.extUserId);
+ }
return {
status: 'success',
};
@@ -85,6 +89,9 @@ async function sendmail(req) {
const res = await mailgunClient.messages.create(mailgunDomain, messageParams);
console.log('Res ', res);
if (res.status === 200) {
+ if (req.params?.extUserId) {
+ await updateMailCount(req.params.extUserId);
+ }
return {
status: 'success',
};
@@ -109,6 +116,9 @@ async function sendmail(req) {
const res = await transporterSMTP.sendMail(messageParams);
console.log('Res ', res);
if (!res.err) {
+ if (req.params?.extUserId) {
+ await updateMailCount(req.params.extUserId);
+ }
return {
status: 'success',
};
@@ -117,6 +127,9 @@ async function sendmail(req) {
const res = await mailgunClient.messages.create(mailgunDomain, messageParams);
console.log('Res ', res);
if (res.status === 200) {
+ if (req.params?.extUserId) {
+ await updateMailCount(req.params.extUserId);
+ }
return {
status: 'success',
};
@@ -124,11 +137,11 @@ async function sendmail(req) {
}
}
} catch (err) {
- console.log('err ', err);
+ console.log('err in sendmailv3', err);
if (err) {
return { status: 'error' };
}
}
}
-export default sendmail;
+export default sendmailv3;
diff --git a/apps/OpenSignServer/index.js b/apps/OpenSignServer/index.js
index 7812b0c6d..521205fa6 100644
--- a/apps/OpenSignServer/index.js
+++ b/apps/OpenSignServer/index.js
@@ -86,7 +86,9 @@ if (process.env.SMTP_ENABLE) {
console.log('Please provide valid Mailgun credentials');
}
}
-
+const mailsender = process.env.SMTP_ENABLE
+ ? process.env.SMTP_USER_EMAIL
+ : process.env.MAILGUN_SENDER;
export const config = {
databaseURI:
process.env.DATABASE_URI || process.env.MONGODB_URI || 'mongodb://localhost:27017/dev',
@@ -102,7 +104,7 @@ export const config = {
verifyUserEmails: isMailAdapter === true ? true : false,
publicServerURL: process.env.SERVER_URL || 'http://localhost:8080/app',
// Your apps name. This will appear in the subject and body of the emails that are sent.
- appName: 'Open Sign',
+ appName: 'Opensign',
allowClientClassCreation: false,
allowExpiredAuthDataToken: false,
encodeParseObjectInCloudFunction: true,
@@ -112,9 +114,7 @@ export const config = {
module: 'parse-server-api-mail-adapter',
options: {
// The email address from which emails are sent.
- sender: process.env.SMTP_ENABLE
- ? process.env.SMTP_USER_EMAIL
- : process.env.MAILGUN_SENDER,
+ sender: 'Opensign™' + ' <' + mailsender + '>',
// The email templates.
templates: {
// The template used by Parse Server to send an email for password
@@ -147,6 +147,14 @@ export const config = {
google: {
enabled: true,
},
+ ldap: {
+ enabled: true,
+ url: 'ldap://ldap.forumsys.com:389',
+ suffix: 'dc=example,dc=com',
+ // dn: 'ou=mathematicians, dc=example, dc=com',
+ groupCn: 'mathematicians',
+ groupFilter: '(&(uniqueMember=uid=,dc=example,dc=com)(objectClass=groupOfUniqueNames))',
+ },
},
};
// Client-keys like the javascript key or the .NET key are not necessary with parse-server