Skip to content

Commit

Permalink
Merge pull request #716 from OpenSignLabs/fix_guestlogin
Browse files Browse the repository at this point in the history
  • Loading branch information
andrew-opensignlabs authored May 10, 2024
2 parents f8145fe + 960fbdb commit 56dd060
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 21 deletions.
6 changes: 4 additions & 2 deletions apps/OpenSign/src/components/AddSigner.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,20 +49,19 @@ const AddSigner = (props) => {
e.preventDefault();
e.stopPropagation();
setIsLoader(true);
if (localStorage.getItem("TenantId")) {
try {
const contactQuery = new Parse.Object("contracts_Contactbook");
contactQuery.set("Name", name);
contactQuery.set("Phone", phone);
contactQuery.set("Email", email);
contactQuery.set("UserRole", "contracts_Guest");

if (localStorage.getItem("TenantId")) {
contactQuery.set("TenantId", {
__type: "Pointer",
className: "partners_Tenant",
objectId: localStorage.getItem("TenantId")
});
}

try {
const _users = Parse.Object.extend("User");
Expand Down Expand Up @@ -188,6 +187,9 @@ const AddSigner = (props) => {
setIsLoader(false);
alert("something went wrong!");
}
}else{
alert('something went wrong, please try again later')
}
};

// Define a function to handle the "add yourself" checkbox
Expand Down
41 changes: 23 additions & 18 deletions apps/OpenSign/src/layout/HomeLayout.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,29 +28,34 @@ const HomeLayout = () => {
const [tourConfigs, setTourConfigs] = useState([]);
const [, setCookie] = useCookies(["accesstoken", "main_Domain"]);

const tenantId = localStorage.getItem("TenantId");
useEffect(() => {
(async () => {
try {
// Use the session token to validate the user
const userQuery = new Parse.Query(Parse.User);
const user = await userQuery.get(Parse.User.current().id, {
sessionToken: localStorage.getItem("accesstoken")
});
if (user) {
localStorage.setItem("profileImg", user.get("ProfilePic") || "");
checkIsSubscribed();
} else {
if (!tenantId) {
setIsUserValid(false);
} else {
(async () => {
try {
// Use the session token to validate the user
const userQuery = new Parse.Query(Parse.User);
const user = await userQuery.get(Parse.User.current().id, {
sessionToken: localStorage.getItem("accesstoken")
});
if (user) {
localStorage.setItem("profileImg", user.get("ProfilePic") || "");
checkIsSubscribed();
} else {
setIsUserValid(false);
}
} catch (error) {
// Session token is invalid or there was an error
setIsUserValid(false);
}
} catch (error) {
// Session token is invalid or there was an error
setIsUserValid(false);
}
})();
saveCookies();
})();
saveCookies();
}

// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);
}, [tenantId]);
//function to use save data in cookies storage
const saveCookies = () => {
const main_Domain = window.location.origin;
Expand Down
2 changes: 1 addition & 1 deletion apps/OpenSign/src/pages/Dashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const Dashboard = () => {
getDashboard(localStorage.getItem("PageLanding"));
}
} else {
navigate("/", { replace: true, state: { from: location } });
navigate("/", { replace: true, state: { from: "" } });
}
// eslint-disable-next-line
}, [id]);
Expand Down

0 comments on commit 56dd060

Please sign in to comment.