🔥 The free & Open Source DocuSign alternative
JavaScript digital-signaturedocument-signingdocusign-alternativedocusign-freee-signatureelectronic-signatureelectronic-signaturesesignesignaturehacktoberfestjavascriptlegaltechmongodbnodejsopen-sourcepdf-signpdf-signaturereactjsself-hostedsign-pdf-files
feat: hide password input for sso and restict sso
prafull-opensignlabsd071986aacdd
diff --git a/apps/OpenSign/src/pages/Login.js b/apps/OpenSign/src/pages/Login.jsindex 9a4d49e75..c49b1e77e 100644--- a/apps/OpenSign/src/pages/Login.js+++ b/apps/OpenSign/src/pages/Login.js@@ -45,6 +45,7 @@ function Login() {});const [isModal, setIsModal] = useState(false);const [image, setImage] = useState();+ const [isLoginSSO, setIsLoginSSO] = useState(false);useEffect(() => {if (localStorage.getItem("accesstoken")) {@@ -1045,10 +1046,14 @@ function Login() {// `handleSignInWithSSO` is trigger when user click sign in with sso and open sso authorize endpointconst handleSignInWithSSO = () => {if (state?.email) {+ setIsLoginSSO(true);const encodedEmail = encodeURIComponent(state.email);const clientUrl = window.location.origin;+ const domain = state.email.split("@")?.pop();+ const ssoApiUrl =+ process.env.SSO_API_URL || "https://sso.opensignlabs.com/api";openInNewTab(- `https://osl-jacksonv2.vercel.app/api/oauth/authorize?response_type=code&provider=saml&tenant=Okta-dev-nxglabs-in&product=OpenSign&redirect_uri=${clientUrl}/sso&state=${encodedEmail}`,+ `${ssoApiUrl}/oauth/authorize?response_type=code&provider=saml&tenant=${domain}&product=OpenSign&redirect_uri=${clientUrl}/sso&state=${encodedEmail}`,"_self");} else {@@ -1122,34 +1127,40 @@ function Login() {required/><hr className="my-2 border-none" />- <label className="block text-xs" htmlFor="password">- Password- </label>- <div className="relative">- <input- id="password"- type={state.passwordVisible ? "text" : "password"}- className="px-3 py-2 w-full border-[1px] border-gray-300 rounded text-xs"- name="password"- value={state.password}- onChange={handleChange}- required- />- <span- className={`absolute top-[50%] right-[10px] -translate-y-[50%] cursor-pointer ${- state.passwordVisible- ? "text-[#007bff]"- : "text-black"- }`}- onClick={togglePasswordVisibility}- >- {state.passwordVisible ? (- <i className="fa fa-eye-slash text-xs pb-1" /> // Close eye icon- ) : (- <i className="fa fa-eye text-xs pb-1 " /> // Open eye icon- )}- </span>- </div>+ {isLoginSSO && (+ <>+ <label className="block text-xs" htmlFor="password">+ Password+ </label>+ <div className="relative">+ <input+ id="password"+ type={+ state.passwordVisible ? "text" : "password"+ }+ className="px-3 py-2 w-full border-[1px] border-gray-300 rounded text-xs"+ name="password"+ value={state.password}+ onChange={handleChange}+ required+ />+ <span+ className={`absolute top-[50%] right-[10px] -translate-y-[50%] cursor-pointer ${+ state.passwordVisible+ ? "text-[#007bff]"+ : "text-black"+ }`}+ onClick={togglePasswordVisibility}+ >+ {state.passwordVisible ? (+ <i className="fa fa-eye-slash text-xs pb-1" /> // Close eye icon+ ) : (+ <i className="fa fa-eye text-xs pb-1 " /> // Open eye icon+ )}+ </span>+ </div>+ </>+ )}<div className="relative mt-1"><NavLinkto="/forgetpassword"@@ -1209,12 +1220,14 @@ function Login() {setThirdpartyLoader={setThirdpartyLoader}/>)}- <div- className="cursor-pointer border-[1px] border-gray-300 rounded px-[40px] py-2 font-semibold text-sm hover:border-[#d2e3fc] hover:bg-[#ecf3feb7]"- onClick={() => handleSignInWithSSO()}- >- Sign in with SSO- </div>+ {isEnableSubscription && (+ <div+ className="cursor-pointer border-[1px] border-gray-300 rounded px-[40px] py-2 font-semibold text-sm hover:border-[#d2e3fc] hover:bg-[#ecf3feb7]"+ onClick={() => handleSignInWithSSO()}+ >+ Sign in with SSO+ </div>+ )}</div></div>{width >= 768 && (diff --git a/apps/OpenSign/src/pages/SSOVerify.js b/apps/OpenSign/src/pages/SSOVerify.jsindex 988e1e5f8..85dbb70bd 100644--- a/apps/OpenSign/src/pages/SSOVerify.js+++ b/apps/OpenSign/src/pages/SSOVerify.js@@ -12,13 +12,14 @@ import { fetchSubscription } from "../constant/Utils";import { useDispatch } from "react-redux";import { showTenant } from "../redux/reducers/ShowTenant";import ModalUi from "../primitives/ModalUi";+import loader from "../assets/images/loader2.gif";const SSOVerify = () => {const location = useLocation();const navigate = useNavigate();const dispatch = useDispatch();const [isModal, setIsModal] = useState(false);- const [ssoErrMsg, setSsoErrMsg] = useState("Verifying SSO...");+ const [message, setMessage] = useState("Verifying SSO...");const [isLoader, setIsLoader] = useState(false);const [userDetails, setUserDetails] = useState({name: "",@@ -48,7 +49,7 @@ const SSOVerify = () => {// `checkExtUser` checks if the user is present in the extended class `contracts_Users` and if not, initiates the new user flowawait checkExtUser(ssosign);} catch (err) {- setSsoErrMsg(err.message);+ setMessage("Error: " + err.message);console.log("err", err.message);}};@@ -81,7 +82,7 @@ const SSOVerify = () => {}} catch (err) {console.log("Err in isextenduser or getuserdetails cloud function", err);- alert(err.message);+ setMessage("Error: " + err.message);}};// `handleSubmitbtn` is used to create a user in the extended class@@ -124,12 +125,12 @@ const SSOVerify = () => {} catch (err) {console.log("error in usersignup", err);localStorage.removeItem("accesstoken");- alert("something went wrong, please try again later.");+ alert("Something went wrong.");setIsLoader(false);}} else {localStorage.removeItem("accesstoken");- alert("Internal server error !");+ alert("Internal server error.");setIsLoader(false);}} else {@@ -251,13 +252,16 @@ const SSOVerify = () => {}} catch (err) {alert("user not exist.");+ setMessage("Error: User not exist.");console.log("err in get extUser", err);}} else {alert("Role does not exists.");+ setMessage("Error: Role does not exists.");}} else {alert("Role does not exists.");+ setMessage("Error: Role does not exists.");}} catch (err) {console.log("err in usergroups", err);@@ -286,8 +290,11 @@ const SSOVerify = () => {}return (<div>- <div className="w-full h-screen flex justify-center items-center text-sm md:text-xl ">- {ssoErrMsg}+ <div className="w-full h-screen flex flex-col justify-center items-center text-sm md:text-xl ">+ {message === "Verifying SSO..." && (+ <img alt="loader" src={loader} className="w-[80px] h-[80px]" />+ )}+ <div className="text-[gray]">{message}</div></div><ModalUi isOpen={isModal} title="Additional Info" showClose={false}><div className="relative">diff --git a/apps/OpenSignServer/auth/authadapter.js b/apps/OpenSignServer/auth/authadapter.jsindex 528ea8176..1e12c7836 100644--- a/apps/OpenSignServer/auth/authadapter.js+++ b/apps/OpenSignServer/auth/authadapter.js@@ -1,7 +1,7 @@import axios from 'axios';import dotenv from 'dotenv';dotenv.config();-const ssoApiUrl = process.env.SSO_API_URL || 'https://osl-jacksonv2.vercel.app/api';+const ssoApiUrl = process.env.SSO_API_URL || 'https://sso.opensignlabs.com/api'; //'https://osl-jacksonv2.vercel.app/api';export const SSOAuth = {// Returns a promise that fulfills if this user mail is valid.validateAuthData: async authData => {diff --git a/apps/OpenSignServer/cloud/parsefunction/ssoSignin.js b/apps/OpenSignServer/cloud/parsefunction/ssoSignin.jsindex 6e50d0639..1067db69d 100644--- a/apps/OpenSignServer/cloud/parsefunction/ssoSignin.js+++ b/apps/OpenSignServer/cloud/parsefunction/ssoSignin.js@@ -4,7 +4,7 @@ const serverUrl = process.env.SERVER_URL;const APPID = process.env.APP_ID;const masterKEY = process.env.MASTER_KEY;const clientUrl = process.env.PUBLIC_URL;-const ssoApiUrl = process.env.SSO_API_URL || 'https://osl-jacksonv2.vercel.app/api';+const ssoApiUrl = process.env.SSO_API_URL || 'https://sso.opensignlabs.com/api'; //'https://osl-jacksonv2.vercel.app/api';/*** ssoSign is function which is used to sign up/sign in with SSO* @param code It is code return by jackson using authorize endpoint