Skip to content

Commit d071986

Browse files
feat: hide password input for sso and restict sso
1 parent afb4de9 commit d071986

File tree

4 files changed

+64
-44
lines changed

4 files changed

+64
-44
lines changed

apps/OpenSign/src/pages/Login.js

Lines changed: 48 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ function Login() {
4545
});
4646
const [isModal, setIsModal] = useState(false);
4747
const [image, setImage] = useState();
48+
const [isLoginSSO, setIsLoginSSO] = useState(false);
4849

4950
useEffect(() => {
5051
if (localStorage.getItem("accesstoken")) {
@@ -1045,10 +1046,14 @@ function Login() {
10451046
// `handleSignInWithSSO` is trigger when user click sign in with sso and open sso authorize endpoint
10461047
const handleSignInWithSSO = () => {
10471048
if (state?.email) {
1049+
setIsLoginSSO(true);
10481050
const encodedEmail = encodeURIComponent(state.email);
10491051
const clientUrl = window.location.origin;
1052+
const domain = state.email.split("@")?.pop();
1053+
const ssoApiUrl =
1054+
process.env.SSO_API_URL || "https://sso.opensignlabs.com/api";
10501055
openInNewTab(
1051-
`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}`,
1056+
`${ssoApiUrl}/oauth/authorize?response_type=code&provider=saml&tenant=${domain}&product=OpenSign&redirect_uri=${clientUrl}/sso&state=${encodedEmail}`,
10521057
"_self"
10531058
);
10541059
} else {
@@ -1122,34 +1127,40 @@ function Login() {
11221127
required
11231128
/>
11241129
<hr className="my-2 border-none" />
1125-
<label className="block text-xs" htmlFor="password">
1126-
Password
1127-
</label>
1128-
<div className="relative">
1129-
<input
1130-
id="password"
1131-
type={state.passwordVisible ? "text" : "password"}
1132-
className="px-3 py-2 w-full border-[1px] border-gray-300 rounded text-xs"
1133-
name="password"
1134-
value={state.password}
1135-
onChange={handleChange}
1136-
required
1137-
/>
1138-
<span
1139-
className={`absolute top-[50%] right-[10px] -translate-y-[50%] cursor-pointer ${
1140-
state.passwordVisible
1141-
? "text-[#007bff]"
1142-
: "text-black"
1143-
}`}
1144-
onClick={togglePasswordVisibility}
1145-
>
1146-
{state.passwordVisible ? (
1147-
<i className="fa fa-eye-slash text-xs pb-1" /> // Close eye icon
1148-
) : (
1149-
<i className="fa fa-eye text-xs pb-1 " /> // Open eye icon
1150-
)}
1151-
</span>
1152-
</div>
1130+
{isLoginSSO && (
1131+
<>
1132+
<label className="block text-xs" htmlFor="password">
1133+
Password
1134+
</label>
1135+
<div className="relative">
1136+
<input
1137+
id="password"
1138+
type={
1139+
state.passwordVisible ? "text" : "password"
1140+
}
1141+
className="px-3 py-2 w-full border-[1px] border-gray-300 rounded text-xs"
1142+
name="password"
1143+
value={state.password}
1144+
onChange={handleChange}
1145+
required
1146+
/>
1147+
<span
1148+
className={`absolute top-[50%] right-[10px] -translate-y-[50%] cursor-pointer ${
1149+
state.passwordVisible
1150+
? "text-[#007bff]"
1151+
: "text-black"
1152+
}`}
1153+
onClick={togglePasswordVisibility}
1154+
>
1155+
{state.passwordVisible ? (
1156+
<i className="fa fa-eye-slash text-xs pb-1" /> // Close eye icon
1157+
) : (
1158+
<i className="fa fa-eye text-xs pb-1 " /> // Open eye icon
1159+
)}
1160+
</span>
1161+
</div>
1162+
</>
1163+
)}
11531164
<div className="relative mt-1">
11541165
<NavLink
11551166
to="/forgetpassword"
@@ -1209,12 +1220,14 @@ function Login() {
12091220
setThirdpartyLoader={setThirdpartyLoader}
12101221
/>
12111222
)}
1212-
<div
1213-
className="cursor-pointer border-[1px] border-gray-300 rounded px-[40px] py-2 font-semibold text-sm hover:border-[#d2e3fc] hover:bg-[#ecf3feb7]"
1214-
onClick={() => handleSignInWithSSO()}
1215-
>
1216-
Sign in with SSO
1217-
</div>
1223+
{isEnableSubscription && (
1224+
<div
1225+
className="cursor-pointer border-[1px] border-gray-300 rounded px-[40px] py-2 font-semibold text-sm hover:border-[#d2e3fc] hover:bg-[#ecf3feb7]"
1226+
onClick={() => handleSignInWithSSO()}
1227+
>
1228+
Sign in with SSO
1229+
</div>
1230+
)}
12181231
</div>
12191232
</div>
12201233
{width >= 768 && (

apps/OpenSign/src/pages/SSOVerify.js

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,14 @@ import { fetchSubscription } from "../constant/Utils";
1212
import { useDispatch } from "react-redux";
1313
import { showTenant } from "../redux/reducers/ShowTenant";
1414
import ModalUi from "../primitives/ModalUi";
15+
import loader from "../assets/images/loader2.gif";
1516

1617
const SSOVerify = () => {
1718
const location = useLocation();
1819
const navigate = useNavigate();
1920
const dispatch = useDispatch();
2021
const [isModal, setIsModal] = useState(false);
21-
const [ssoErrMsg, setSsoErrMsg] = useState("Verifying SSO...");
22+
const [message, setMessage] = useState("Verifying SSO...");
2223
const [isLoader, setIsLoader] = useState(false);
2324
const [userDetails, setUserDetails] = useState({
2425
name: "",
@@ -48,7 +49,7 @@ const SSOVerify = () => {
4849
// `checkExtUser` checks if the user is present in the extended class `contracts_Users` and if not, initiates the new user flow
4950
await checkExtUser(ssosign);
5051
} catch (err) {
51-
setSsoErrMsg(err.message);
52+
setMessage("Error: " + err.message);
5253
console.log("err", err.message);
5354
}
5455
};
@@ -81,7 +82,7 @@ const SSOVerify = () => {
8182
}
8283
} catch (err) {
8384
console.log("Err in isextenduser or getuserdetails cloud function", err);
84-
alert(err.message);
85+
setMessage("Error: " + err.message);
8586
}
8687
};
8788
// `handleSubmitbtn` is used to create a user in the extended class
@@ -124,12 +125,12 @@ const SSOVerify = () => {
124125
} catch (err) {
125126
console.log("error in usersignup", err);
126127
localStorage.removeItem("accesstoken");
127-
alert("something went wrong, please try again later.");
128+
alert("Something went wrong.");
128129
setIsLoader(false);
129130
}
130131
} else {
131132
localStorage.removeItem("accesstoken");
132-
alert("Internal server error !");
133+
alert("Internal server error.");
133134
setIsLoader(false);
134135
}
135136
} else {
@@ -251,13 +252,16 @@ const SSOVerify = () => {
251252
}
252253
} catch (err) {
253254
alert("user not exist.");
255+
setMessage("Error: User not exist.");
254256
console.log("err in get extUser", err);
255257
}
256258
} else {
257259
alert("Role does not exists.");
260+
setMessage("Error: Role does not exists.");
258261
}
259262
} else {
260263
alert("Role does not exists.");
264+
setMessage("Error: Role does not exists.");
261265
}
262266
} catch (err) {
263267
console.log("err in usergroups", err);
@@ -286,8 +290,11 @@ const SSOVerify = () => {
286290
}
287291
return (
288292
<div>
289-
<div className="w-full h-screen flex justify-center items-center text-sm md:text-xl ">
290-
{ssoErrMsg}
293+
<div className="w-full h-screen flex flex-col justify-center items-center text-sm md:text-xl ">
294+
{message === "Verifying SSO..." && (
295+
<img alt="loader" src={loader} className="w-[80px] h-[80px]" />
296+
)}
297+
<div className="text-[gray]">{message}</div>
291298
</div>
292299
<ModalUi isOpen={isModal} title="Additional Info" showClose={false}>
293300
<div className="relative">

apps/OpenSignServer/auth/authadapter.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import axios from 'axios';
22
import dotenv from 'dotenv';
33
dotenv.config();
4-
const ssoApiUrl = process.env.SSO_API_URL || 'https://osl-jacksonv2.vercel.app/api';
4+
const ssoApiUrl = process.env.SSO_API_URL || 'https://sso.opensignlabs.com/api'; //'https://osl-jacksonv2.vercel.app/api';
55
export const SSOAuth = {
66
// Returns a promise that fulfills if this user mail is valid.
77
validateAuthData: async authData => {

apps/OpenSignServer/cloud/parsefunction/ssoSignin.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ const serverUrl = process.env.SERVER_URL;
44
const APPID = process.env.APP_ID;
55
const masterKEY = process.env.MASTER_KEY;
66
const clientUrl = process.env.PUBLIC_URL;
7-
const ssoApiUrl = process.env.SSO_API_URL || 'https://osl-jacksonv2.vercel.app/api';
7+
const ssoApiUrl = process.env.SSO_API_URL || 'https://sso.opensignlabs.com/api'; //'https://osl-jacksonv2.vercel.app/api';
88
/**
99
* ssoSign is function which is used to sign up/sign in with SSO
1010
* @param code It is code return by jackson using authorize endpoint

0 commit comments

Comments
 (0)