Skip to content

Commit bc5c8ca

Browse files
feat: existing user can sign in with sso
1 parent be93e6a commit bc5c8ca

File tree

10 files changed

+497
-151
lines changed

10 files changed

+497
-151
lines changed

apps/OpenSign/src/App.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import PlaceHolderSign from "./pages/PlaceHolderSign";
1616
import PdfRequestFiles from "./pages/PdfRequestFiles";
1717
import LazyPage from "./primitives/LazyPage";
1818
import { isEnableSubscription } from "./constant/const";
19+
import SSOVerify from "./pages/SSOVerify";
1920
const DebugPdf = lazy(() => import("./pages/DebugPdf"));
2021
const ForgetPassword = lazy(() => import("./pages/ForgetPassword"));
2122
const GuestLogin = lazy(() => import("./pages/GuestLogin"));
@@ -181,6 +182,7 @@ function App() {
181182
element={<PdfRequestFiles />}
182183
/>
183184
</Route>
185+
<Route path="/sso" element={<SSOVerify />} />
184186
<Route path="*" element={<PageNotFound />} />
185187
</Routes>
186188
</BrowserRouter>

apps/OpenSign/src/components/Header.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,9 @@ const Header = ({ showSidebar }) => {
4444

4545
const closeDropdown = () => {
4646
setIsOpen(false);
47-
Parse.User.logOut();
47+
if (Parse?.User?.current()) {
48+
Parse.User.logOut();
49+
}
4850
let appdata = localStorage.getItem("userSettings");
4951
let applogo = localStorage.getItem("appLogo");
5052
let appName = localStorage.getItem("appName");

apps/OpenSign/src/pages/Login.js

Lines changed: 111 additions & 114 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import Alert from "../primitives/Alert";
1919
import { appInfo } from "../constant/appinfo";
2020
import { fetchAppInfo } from "../redux/reducers/infoReducer";
2121
import { showTenant } from "../redux/reducers/ShowTenant";
22-
import { fetchSubscription, getAppLogo } from "../constant/Utils";
22+
import { fetchSubscription, getAppLogo, openInNewTab } from "../constant/Utils";
2323
function Login() {
2424
const navigate = useNavigate();
2525
const location = useLocation();
@@ -1016,8 +1016,9 @@ function Login() {
10161016

10171017
const handleCloseModal = () => {
10181018
setIsModal(false);
1019-
Parse.User.logOut();
1020-
1019+
if (Parse?.User?.current()) {
1020+
Parse.User.logOut();
1021+
}
10211022
let appdata = localStorage.getItem("userSettings");
10221023
let applogo = localStorage.getItem("appLogo");
10231024
let appName = localStorage.getItem("appName");
@@ -1040,6 +1041,15 @@ function Login() {
10401041
localStorage.setItem("baseUrl", baseUrl);
10411042
localStorage.setItem("parseAppId", appid);
10421043
};
1044+
const handleSignInWithSSO = () => {
1045+
if (state?.email) {
1046+
openInNewTab(
1047+
`https://osl-jacksonv2.vercel.app/api/oauth/authorize?response_type=code&provider=saml&tenant=Okta-dev-nxglabs-in&product=OpenSign&redirect_uri=http://localhost:3000/sso&state=${state.email}`
1048+
);
1049+
} else {
1050+
alert("Please provide email.");
1051+
}
1052+
};
10431053
return (
10441054
<div className="bg-white">
10451055
<Title title={"Login Page"} />
@@ -1087,136 +1097,123 @@ function Login() {
10871097
</div>
10881098
<div className="grid grid-cols-1 md:grid-cols-2 gap-x-2">
10891099
<div>
1090-
<div>
1091-
<form onSubmit={handleSubmit} aria-label="Login Form">
1092-
<h1 className="text-[30px] mt-6">Welcome Back!</h1>
1093-
<fieldset>
1094-
<legend className="text-[12px] text-[#878787]">
1095-
Login to your account
1096-
</legend>
1097-
<div className="px-6 py-4 outline outline-1 outline-slate-300/50 my-2 rounded shadow-md">
1098-
<label className="block text-xs" htmlFor="email">
1099-
Username
1100-
</label>
1100+
<form onSubmit={handleSubmit} aria-label="Login Form">
1101+
<h1 className="text-[30px] mt-6">Welcome Back!</h1>
1102+
<fieldset>
1103+
<legend className="text-[12px] text-[#878787]">
1104+
Login to your account
1105+
</legend>
1106+
<div className="px-6 py-4 outline outline-1 outline-slate-300/50 my-2 rounded shadow-md">
1107+
<label className="block text-xs" htmlFor="email">
1108+
Email
1109+
</label>
1110+
<input
1111+
id="email"
1112+
type="text"
1113+
className="px-3 py-2 w-full border-[1px] border-gray-300 rounded text-xs"
1114+
name="email"
1115+
value={state.email}
1116+
onChange={handleChange}
1117+
required
1118+
/>
1119+
<hr className="my-2 border-none" />
1120+
<label className="block text-xs" htmlFor="password">
1121+
Password
1122+
</label>
1123+
<div className="relative">
11011124
<input
1102-
id="email"
1103-
type="text"
1125+
id="password"
1126+
type={state.passwordVisible ? "text" : "password"}
11041127
className="px-3 py-2 w-full border-[1px] border-gray-300 rounded text-xs"
1105-
name="email"
1106-
value={state.email}
1128+
name="password"
1129+
value={state.password}
11071130
onChange={handleChange}
11081131
required
11091132
/>
1110-
<hr className="my-2 border-none" />
1111-
<label className="block text-xs" htmlFor="password">
1112-
Password
1113-
</label>
1114-
<div className="relative">
1115-
<input
1116-
id="password"
1117-
type={state.passwordVisible ? "text" : "password"}
1118-
className="px-3 py-2 w-full border-[1px] border-gray-300 rounded text-xs"
1119-
name="password"
1120-
value={state.password}
1121-
onChange={handleChange}
1122-
required
1123-
/>
1124-
<span
1125-
className={`absolute top-[50%] right-[10px] -translate-y-[50%] cursor-pointer ${
1126-
state.passwordVisible
1127-
? "text-[#007bff]"
1128-
: "text-black"
1129-
}`}
1130-
onClick={togglePasswordVisibility}
1131-
>
1132-
{state.passwordVisible ? (
1133-
<i className="fa fa-eye-slash text-xs pb-1" /> // Close eye icon
1134-
) : (
1135-
<i className="fa fa-eye text-xs pb-1 " /> // Open eye icon
1136-
)}
1137-
</span>
1138-
</div>
1139-
<div className="relative mt-1">
1140-
<NavLink
1141-
to="/forgetpassword"
1142-
className="text-[13px] text-[#002864] hover:underline underline-offset-1 focus:outline-none cursor-pointer ml-1"
1143-
>
1144-
Forgot Password?
1145-
</NavLink>
1146-
</div>
1133+
<span
1134+
className={`absolute top-[50%] right-[10px] -translate-y-[50%] cursor-pointer ${
1135+
state.passwordVisible
1136+
? "text-[#007bff]"
1137+
: "text-black"
1138+
}`}
1139+
onClick={togglePasswordVisibility}
1140+
>
1141+
{state.passwordVisible ? (
1142+
<i className="fa fa-eye-slash text-xs pb-1" /> // Close eye icon
1143+
) : (
1144+
<i className="fa fa-eye text-xs pb-1 " /> // Open eye icon
1145+
)}
1146+
</span>
1147+
</div>
1148+
<div className="relative mt-1">
1149+
<NavLink
1150+
to="/forgetpassword"
1151+
className="text-[13px] text-[#002864] hover:underline underline-offset-1 focus:outline-none cursor-pointer ml-1"
1152+
>
1153+
Forgot Password?
1154+
</NavLink>
11471155
</div>
1148-
</fieldset>
1149-
<div className="flex flex-col md:flex-row justify-between items-stretch gap-8 text-center text-xs font-bold mt-2">
1150-
<button
1151-
type="submit"
1152-
className="rounded-sm bg-[#3ac9d6] text-white w-full py-3 shadow outline-none uppercase focus:ring-2 focus:ring-blue-600"
1153-
disabled={state.loading}
1154-
>
1155-
{state.loading ? "Loading..." : "Login"}
1156-
</button>
1157-
<NavLink
1158-
className="rounded-sm cursor-pointer bg-white border-[1px] border-[#15b4e9] text-[#15b4e9] w-full py-3 shadow uppercase"
1159-
to={
1160-
location.search
1161-
? "/signup" + location.search
1162-
: "/signup"
1163-
}
1164-
style={width < 768 ? { textAlign: "center" } : {}}
1165-
>
1166-
Create Account
1167-
</NavLink>
1168-
</div>
1169-
</form>
1170-
<br />
1171-
{(appInfo.fbAppId || appInfo.googleClietId) && (
1172-
<div className="text-sm flex justify-center items-center">
1173-
<hr className="border-[1px] border-gray-300 w-full" />
1174-
<span className="px-2 text-gray-500 cursor-default">
1175-
OR
1176-
</span>
1177-
<hr className="border-[1px] border-gray-300 w-full" />
11781156
</div>
1179-
)}
1180-
<br />
1181-
<div
1182-
style={{
1183-
textAlign: "center",
1184-
display: "flex",
1185-
alignItems: "center",
1186-
justifyContent: "center"
1187-
}}
1188-
>
1189-
{/* {appInfo.fbAppId && appInfo.fbAppId !== "" ? (
1157+
</fieldset>
1158+
<div className="flex flex-col md:flex-row justify-between items-stretch gap-8 text-center text-xs font-bold mt-2">
1159+
<button
1160+
type="submit"
1161+
className="rounded-sm bg-[#3ac9d6] text-white w-full py-3 shadow outline-none uppercase focus:ring-2 focus:ring-blue-600"
1162+
disabled={state.loading}
1163+
>
1164+
{state.loading ? "Loading..." : "Login"}
1165+
</button>
1166+
<NavLink
1167+
className="rounded-sm cursor-pointer bg-white border-[1px] border-[#15b4e9] text-[#15b4e9] w-full py-3 shadow uppercase"
1168+
to={
1169+
location.search
1170+
? "/signup" + location.search
1171+
: "/signup"
1172+
}
1173+
style={width < 768 ? { textAlign: "center" } : {}}
1174+
>
1175+
Create Account
1176+
</NavLink>
1177+
</div>
1178+
</form>
1179+
<br />
1180+
{appInfo.googleClietId && (
1181+
<div className="text-sm flex justify-center items-center">
1182+
<hr className="border-[1px] border-gray-300 w-full" />
1183+
<span className="px-2 text-gray-500 cursor-default">
1184+
OR
1185+
</span>
1186+
<hr className="border-[1px] border-gray-300 w-full" />
1187+
</div>
1188+
)}
1189+
<br />
1190+
<div className="flex flex-col justify-center items-center gap-y-3">
1191+
{/* {appInfo?.fbAppId && (
11901192
<LoginFacebook
11911193
FBCred={appInfo.fbAppId}
11921194
thirdpartyLoginfn={thirdpartyLoginfn}
11931195
thirdpartyLoader={state.thirdpartyLoader}
11941196
setThirdpartyLoader={setThirdpartyLoader}
11951197
/>
1196-
) : null} */}
1197-
</div>
1198-
<div style={{ margin: "10px 0" }}></div>
1198+
)} */}
1199+
{appInfo?.googleClietId && (
1200+
<GoogleSignInBtn
1201+
GoogleCred={appInfo.googleClietId}
1202+
thirdpartyLoginfn={thirdpartyLoginfn}
1203+
thirdpartyLoader={state.thirdpartyLoader}
1204+
setThirdpartyLoader={setThirdpartyLoader}
1205+
/>
1206+
)}
11991207
<div
1200-
style={{
1201-
textAlign: "center",
1202-
display: "flex",
1203-
alignItems: "center",
1204-
justifyContent: "center"
1205-
}}
1208+
className="cursor-pointer border-[1px] border-gray-300 rounded px-[40px] py-2 font-semibold text-sm hover:border-[#d2e3fc] hover:bg-[#ecf3feb7]"
1209+
onClick={() => handleSignInWithSSO()}
12061210
>
1207-
{appInfo.googleClietId && appInfo.googleClietId !== "" ? (
1208-
<GoogleSignInBtn
1209-
GoogleCred={appInfo.googleClietId}
1210-
thirdpartyLoginfn={thirdpartyLoginfn}
1211-
thirdpartyLoader={state.thirdpartyLoader}
1212-
setThirdpartyLoader={setThirdpartyLoader}
1213-
/>
1214-
) : null}
1211+
Sign in with SSO
12151212
</div>
12161213
</div>
12171214
</div>
12181215
{width >= 768 && (
1219-
<div className="self-center">
1216+
<div className="place-self-center">
12201217
<div className="mx-auto md:w-[300px] lg:w-[400px] xl:w-[500px]">
12211218
<img
12221219
src={login_img}

0 commit comments

Comments
 (0)