mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-06 21:27:10 +00:00
Lint and move redirectSSO into controller
This commit is contained in:
@@ -9,6 +9,15 @@ import {
|
|||||||
import { getSSOConfigHelper } from "../../helpers/organizations";
|
import { getSSOConfigHelper } from "../../helpers/organizations";
|
||||||
import { client } from "../../../config";
|
import { client } from "../../../config";
|
||||||
import { ResourceNotFoundError } from "../../../utils/errors";
|
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) => {
|
export const getSSOConfig = async (req: Request, res: Response) => {
|
||||||
const organizationId = req.query.organizationId as string;
|
const organizationId = req.query.organizationId as string;
|
||||||
|
|||||||
@@ -14,9 +14,6 @@ import {
|
|||||||
OWNER,
|
OWNER,
|
||||||
ADMIN
|
ADMIN
|
||||||
} from "../../../variables";
|
} from "../../../variables";
|
||||||
import {
|
|
||||||
getSiteURL
|
|
||||||
} from "../../../config";
|
|
||||||
|
|
||||||
router.get(
|
router.get(
|
||||||
"/redirect/google",
|
"/redirect/google",
|
||||||
@@ -33,13 +30,7 @@ router.get(
|
|||||||
failureRedirect: "/login/provider/error",
|
failureRedirect: "/login/provider/error",
|
||||||
session: false
|
session: false
|
||||||
}),
|
}),
|
||||||
async (req, res) => {
|
ssoController.redirectSSO
|
||||||
if (req.isUserCompleted) {
|
|
||||||
res.redirect(`${await getSiteURL()}/login/sso?token=${encodeURIComponent(req.providerAuthToken)}`);
|
|
||||||
} else {
|
|
||||||
res.redirect(`${await getSiteURL()}/signup/sso?token=${encodeURIComponent(req.providerAuthToken)}`);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
);
|
);
|
||||||
|
|
||||||
router.get(
|
router.get(
|
||||||
@@ -56,13 +47,7 @@ router.post("/saml2/:ssoIdentifier",
|
|||||||
failureFlash: true,
|
failureFlash: true,
|
||||||
session: false
|
session: false
|
||||||
}),
|
}),
|
||||||
async (req, res) => { // TODO: move this into controller
|
ssoController.redirectSSO
|
||||||
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)}`);
|
|
||||||
}
|
|
||||||
);
|
);
|
||||||
|
|
||||||
router.get(
|
router.get(
|
||||||
|
|||||||
@@ -1,8 +1,9 @@
|
|||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import Link from "next/link";
|
import Link from "next/link";
|
||||||
import { useRouter } from "next/router";
|
import { useRouter } from "next/router";
|
||||||
import { faGoogle } from '@fortawesome/free-brands-svg-icons';
|
import { faGoogle } from "@fortawesome/free-brands-svg-icons";
|
||||||
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
||||||
|
|
||||||
import { Button } from "../v2";
|
import { Button } from "../v2";
|
||||||
|
|
||||||
export default function InitialSignupStep({
|
export default function InitialSignupStep({
|
||||||
@@ -38,13 +39,13 @@ export default function InitialSignupStep({
|
|||||||
colorSchema="primary"
|
colorSchema="primary"
|
||||||
variant="solid"
|
variant="solid"
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
window.open('/api/v1/sso/redirect/google');
|
window.open("/api/v1/sso/redirect/google");
|
||||||
window.close();
|
window.close();
|
||||||
}}
|
}}
|
||||||
leftIcon={<FontAwesomeIcon icon={faGoogle} className="mr-1" />}
|
leftIcon={<FontAwesomeIcon icon={faGoogle} className="mr-1" />}
|
||||||
className="h-14 w-full mx-0"
|
className="h-14 w-full mx-0"
|
||||||
>
|
>
|
||||||
{t('signup.continue-with-google')}
|
{t("signup.continue-with-google")}
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
<div className='lg:w-1/6 w-1/4 min-w-[20rem] text-center rounded-md mt-4'>
|
<div className='lg:w-1/6 w-1/4 min-w-[20rem] text-center rounded-md mt-4'>
|
||||||
|
|||||||
@@ -164,13 +164,13 @@ export const InitialStep = ({
|
|||||||
colorSchema="primary"
|
colorSchema="primary"
|
||||||
variant="solid"
|
variant="solid"
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
window.open('/api/v1/sso/redirect/google');
|
window.open("/api/v1/sso/redirect/google");
|
||||||
window.close();
|
window.close();
|
||||||
}}
|
}}
|
||||||
leftIcon={<FontAwesomeIcon icon={faGoogle} className="mr-1" />}
|
leftIcon={<FontAwesomeIcon icon={faGoogle} className="mr-1" />}
|
||||||
className="h-14 w-full mx-0"
|
className="h-14 w-full mx-0"
|
||||||
>
|
>
|
||||||
{t('login.continue-with-google')}
|
{t("login.continue-with-google")}
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
<div className='lg:w-1/6 w-1/4 min-w-[20rem] text-center rounded-md mt-4'>
|
<div className='lg:w-1/6 w-1/4 min-w-[20rem] text-center rounded-md mt-4'>
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import { faPlus } from "@fortawesome/free-solid-svg-icons";
|
import { faPlus } from "@fortawesome/free-solid-svg-icons";
|
||||||
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
||||||
|
|
||||||
import { useNotificationContext } from "@app/components/context/Notifications/NotificationProvider";
|
import { useNotificationContext } from "@app/components/context/Notifications/NotificationProvider";
|
||||||
import { Button, Switch, UpgradePlanModal } from "@app/components/v2";
|
import { Button, Switch, UpgradePlanModal } from "@app/components/v2";
|
||||||
import { useOrganization, useSubscription } from "@app/context";
|
import { useOrganization, useSubscription } from "@app/context";
|
||||||
@@ -8,6 +9,7 @@ import {
|
|||||||
useUpdateSSOConfig
|
useUpdateSSOConfig
|
||||||
} from "@app/hooks/api";
|
} from "@app/hooks/api";
|
||||||
import { usePopUp } from "@app/hooks/usePopUp";
|
import { usePopUp } from "@app/hooks/usePopUp";
|
||||||
|
|
||||||
import { SSOModal } from "./SSOModal";
|
import { SSOModal } from "./SSOModal";
|
||||||
|
|
||||||
const ssoAuthProviderMap: { [key: string]: string } = {
|
const ssoAuthProviderMap: { [key: string]: string } = {
|
||||||
|
|||||||
@@ -1,19 +1,21 @@
|
|||||||
import { Fragment } from "react"
|
import { Fragment } from "react"
|
||||||
import { Tab } from "@headlessui/react"
|
import { Tab } from "@headlessui/react"
|
||||||
import { OrgAuthTab } from "../OrgAuthTab";
|
|
||||||
import { OrgGeneralTab } from "../OrgGeneralTab";
|
import { useOrganization,useUser } from "@app/context";
|
||||||
import { useUser, useOrganization } from "@app/context";
|
|
||||||
import {
|
import {
|
||||||
useGetOrgUsers
|
useGetOrgUsers
|
||||||
} from "@app/hooks/api";
|
} from "@app/hooks/api";
|
||||||
|
|
||||||
|
import { OrgAuthTab } from "../OrgAuthTab";
|
||||||
|
import { OrgGeneralTab } from "../OrgGeneralTab";
|
||||||
|
|
||||||
export const OrgTabGroup = () => {
|
export const OrgTabGroup = () => {
|
||||||
const { currentOrg } = useOrganization();
|
const { currentOrg } = useOrganization();
|
||||||
const { user } = useUser();
|
const { user } = useUser();
|
||||||
const { data } = useGetOrgUsers(currentOrg?._id ?? "");
|
const { data } = useGetOrgUsers(currentOrg?._id ?? "");
|
||||||
|
|
||||||
const isRoleSufficient = data?.some((orgUser) => {
|
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 = [
|
const tabs = [
|
||||||
|
|||||||
Reference in New Issue
Block a user