Skip to content

Commit a6d97d5

Browse files
authored
Merge pull request #688 from OpenSignLabs/main
Main
2 parents c564b57 + ff9a495 commit a6d97d5

File tree

2 files changed

+20
-10
lines changed

2 files changed

+20
-10
lines changed

apps/OpenSign/src/components/LoginGoogle.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,8 @@ const GoogleSignInBtn = ({
115115
// console.log("payload ", payload);
116116
if (payload && payload.sessiontoken) {
117117
// setThirdpartyLoader(true);
118-
const billingDate =
119-
extRes.get("Next_billing_date") && extRes.get("Next_billing_date");
118+
// const billingDate =
119+
// extRes.get("Next_billing_date") && extRes.get("Next_billing_date");
120120
// console.log("billingDate expired", billingDate > new Date());
121121
const LocalUserDetails = {
122122
name: details.Name,
@@ -125,7 +125,7 @@ const GoogleSignInBtn = ({
125125
company: extRes.get("Company")
126126
};
127127
localStorage.setItem("userDetails", JSON.stringify(LocalUserDetails));
128-
thirdpartyLoginfn(payload.sessiontoken, billingDate);
128+
thirdpartyLoginfn(payload.sessiontoken);
129129
}
130130
return { msg: "exist" };
131131
} else {

apps/OpenSign/src/pages/Login.js

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,7 @@ function Login() {
422422
alert("Somenthing went wrong, please try again later!");
423423
}
424424
};
425-
const thirdpartyLoginfn = async (sessionToken, billingDate) => {
425+
const thirdpartyLoginfn = async (sessionToken) => {
426426
const baseUrl = localStorage.getItem("baseUrl");
427427
const parseAppId = localStorage.getItem("parseAppId");
428428
const res = await axios.get(baseUrl + "users/me", {
@@ -521,7 +521,7 @@ function Login() {
521521
await Parse.Cloud.run("getUserDetails", {
522522
email: currentUser.get("email")
523523
}).then(
524-
(result) => {
524+
async (result) => {
525525
let tenentInfo = [];
526526
const results = [result];
527527
if (results) {
@@ -571,7 +571,7 @@ function Login() {
571571
setState({ ...state, loading: false });
572572
navigate("/");
573573
} else {
574-
extendedInfo.forEach((x) => {
574+
extendedInfo.forEach(async (x) => {
575575
if (x.TenantId) {
576576
let obj = {
577577
tenentId: x.TenantId.objectId,
@@ -608,8 +608,13 @@ function Login() {
608608
setThirdpartyLoader(false);
609609
setState({ ...state, loading: false });
610610
if (isEnableSubscription) {
611-
if (billingDate) {
612-
if (billingDate > new Date()) {
611+
const res = await fetchSubscription();
612+
const freeplan = res.plan;
613+
const billingDate = res.billingDate;
614+
if (freeplan === "freeplan") {
615+
navigate(redirectUrl);
616+
} else if (billingDate) {
617+
if (new Date(billingDate) > new Date()) {
613618
localStorage.removeItem("userDetails");
614619
navigate(redirectUrl);
615620
} else {
@@ -644,8 +649,13 @@ function Login() {
644649
setState({ ...state, loading: false });
645650
setThirdpartyLoader(false);
646651
if (isEnableSubscription) {
647-
if (billingDate) {
648-
if (billingDate > new Date()) {
652+
const res = await fetchSubscription();
653+
const freeplan = res.plan;
654+
const billingDate = res.billingDate;
655+
if (freeplan === "freeplan") {
656+
navigate(redirectUrl);
657+
} else if (billingDate) {
658+
if (new Date(billingDate) > new Date()) {
649659
localStorage.removeItem("userDetails");
650660
// Redirect to the appropriate URL after successful login
651661
navigate(redirectUrl);

0 commit comments

Comments
 (0)