Skip to content

Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.

Lint and move redirectSSO into controller

Tuan Dang75e90201c00d
diff --git a/backend/src/ee/controllers/v1/ssoController.ts b/backend/src/ee/controllers/v1/ssoController.ts
index 2eed08cd11..88af8915e0 100644
--- a/backend/src/ee/controllers/v1/ssoController.ts
+++ b/backend/src/ee/controllers/v1/ssoController.ts
@@ -9,6 +9,15 @@ import {
import { getSSOConfigHelper } from "../../helpers/organizations";
import { client } from "../../../config";
import { ResourceNotFoundError } from "../../../utils/errors";
+import { getSiteURL } from "../../../config";
+
+export const redirectSSO = async (req: Request, res: Response) => {
+ if (req.isUserCompleted) {
+ return res.redirect(`${await getSiteURL()}/login/sso?token=${encodeURIComponent(req.providerAuthToken)}`);
+ }
+
+ return res.redirect(`${await getSiteURL()}/signup/sso?token=${encodeURIComponent(req.providerAuthToken)}`);
+}
export const getSSOConfig = async (req: Request, res: Response) => {
const organizationId = req.query.organizationId as string;
diff --git a/backend/src/ee/routes/v1/sso.ts b/backend/src/ee/routes/v1/sso.ts
index 5a2b3bb3da..cf949f2f14 100644
--- a/backend/src/ee/routes/v1/sso.ts
+++ b/backend/src/ee/routes/v1/sso.ts
@@ -14,9 +14,6 @@ import {
OWNER,
ADMIN
} from "../../../variables";
-import {
- getSiteURL
-} from "../../../config";
router.get(
"/redirect/google",
@@ -33,13 +30,7 @@ router.get(
failureRedirect: "/login/provider/error",
session: false
}),
- async (req, res) => {
- if (req.isUserCompleted) {
- res.redirect(`${await getSiteURL()}/login/sso?token=${encodeURIComponent(req.providerAuthToken)}`);
- } else {
- res.redirect(`${await getSiteURL()}/signup/sso?token=${encodeURIComponent(req.providerAuthToken)}`);
- }
- }
+ ssoController.redirectSSO
);
router.get(
@@ -56,13 +47,7 @@ router.post("/saml2/:ssoIdentifier",
failureFlash: true,
session: false
}),
- async (req, res) => { // TODO: move this into controller
- if (req.isUserCompleted) {
- return res.redirect(`${await getSiteURL()}/login/sso?token=${encodeURIComponent(req.providerAuthToken)}`);
- }
-
- return res.redirect(`${await getSiteURL()}/signup/sso?token=${encodeURIComponent(req.providerAuthToken)}`);
- }
+ ssoController.redirectSSO
);
router.get(
diff --git a/frontend/src/components/signup/InitialSignupStep.tsx b/frontend/src/components/signup/InitialSignupStep.tsx
index e45c769eb1..fb965470ec 100644
--- a/frontend/src/components/signup/InitialSignupStep.tsx
+++ b/frontend/src/components/signup/InitialSignupStep.tsx
@@ -1,8 +1,9 @@
import { useTranslation } from "react-i18next";
import Link from "next/link";
import { useRouter } from "next/router";
-import { faGoogle } from '@fortawesome/free-brands-svg-icons';
-import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
+import { faGoogle } from "@fortawesome/free-brands-svg-icons";
+import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
+
import { Button } from "../v2";
export default function InitialSignupStep({
@@ -38,13 +39,13 @@ export default function InitialSignupStep({
colorSchema="primary"
variant="solid"
onClick={() => {
- window.open('/api/v1/sso/redirect/google');
+ window.open("/api/v1/sso/redirect/google");
window.close();
}}
leftIcon={<FontAwesomeIcon icon={faGoogle} className="mr-1" />}
className="h-14 w-full mx-0"
>
- {t('signup.continue-with-google')}
+ {t("signup.continue-with-google")}
</Button>
</div>
<div className='lg:w-1/6 w-1/4 min-w-[20rem] text-center rounded-md mt-4'>
diff --git a/frontend/src/views/Login/components/InitialStep/InitialStep.tsx b/frontend/src/views/Login/components/InitialStep/InitialStep.tsx
index f7667ccb39..abc6adf566 100644
--- a/frontend/src/views/Login/components/InitialStep/InitialStep.tsx
+++ b/frontend/src/views/Login/components/InitialStep/InitialStep.tsx
@@ -164,13 +164,13 @@ export const InitialStep = ({
colorSchema="primary"
variant="solid"
onClick={() => {
- window.open('/api/v1/sso/redirect/google');
+ window.open("/api/v1/sso/redirect/google");
window.close();
}}
leftIcon={<FontAwesomeIcon icon={faGoogle} className="mr-1" />}
className="h-14 w-full mx-0"
>
- {t('login.continue-with-google')}
+ {t("login.continue-with-google")}
</Button>
</div>
<div className='lg:w-1/6 w-1/4 min-w-[20rem] text-center rounded-md mt-4'>
diff --git a/frontend/src/views/Settings/OrgSettingsPage/components/OrgAuthTab/OrgSSOSection.tsx b/frontend/src/views/Settings/OrgSettingsPage/components/OrgAuthTab/OrgSSOSection.tsx
index 49da45e9f7..8173267887 100644
--- a/frontend/src/views/Settings/OrgSettingsPage/components/OrgAuthTab/OrgSSOSection.tsx
+++ b/frontend/src/views/Settings/OrgSettingsPage/components/OrgAuthTab/OrgSSOSection.tsx
@@ -1,5 +1,6 @@
import { faPlus } from "@fortawesome/free-solid-svg-icons";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
+
import { useNotificationContext } from "@app/components/context/Notifications/NotificationProvider";
import { Button, Switch, UpgradePlanModal } from "@app/components/v2";
import { useOrganization, useSubscription } from "@app/context";
@@ -8,6 +9,7 @@ import {
useUpdateSSOConfig
} from "@app/hooks/api";
import { usePopUp } from "@app/hooks/usePopUp";
+
import { SSOModal } from "./SSOModal";
const ssoAuthProviderMap: { [key: string]: string } = {
diff --git a/frontend/src/views/Settings/OrgSettingsPage/components/OrgTabGroup/OrgTabGroup.tsx b/frontend/src/views/Settings/OrgSettingsPage/components/OrgTabGroup/OrgTabGroup.tsx
index 05d0b5d87b..b955b9faa1 100644
--- a/frontend/src/views/Settings/OrgSettingsPage/components/OrgTabGroup/OrgTabGroup.tsx
+++ b/frontend/src/views/Settings/OrgSettingsPage/components/OrgTabGroup/OrgTabGroup.tsx
@@ -1,19 +1,21 @@
import { Fragment } from "react"
import { Tab } from "@headlessui/react"
-import { OrgAuthTab } from "../OrgAuthTab";
-import { OrgGeneralTab } from "../OrgGeneralTab";
-import { useUser, useOrganization } from "@app/context";
+
+import { useOrganization,useUser } from "@app/context";
import {
useGetOrgUsers
} from "@app/hooks/api";
+import { OrgAuthTab } from "../OrgAuthTab";
+import { OrgGeneralTab } from "../OrgGeneralTab";
+
export const OrgTabGroup = () => {
const { currentOrg } = useOrganization();
const { user } = useUser();
const { data } = useGetOrgUsers(currentOrg?._id ?? "");
const isRoleSufficient = data?.some((orgUser) => {
- return orgUser.role !== 'member' && orgUser.user._id === user._id;
+ return orgUser.role !== "member" && orgUser.user._id === user._id;
});
const tabs = [