Feat: Default SAML/LDAP organization slug

This commit is contained in:
Daniel Hougaard
2024-06-24 19:08:19 +02:00
parent 56bc25025a
commit 4905ad1f48
@@ -1,4 +1,4 @@
import { useEffect, useRef,useState } from "react"; import { useEffect, useRef, useState } from "react";
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";
@@ -16,7 +16,7 @@ import { useOauthTokenExchange, useSelectOrganization } from "@app/hooks/api";
import { fetchOrganizations } from "@app/hooks/api/organization/queries"; import { fetchOrganizations } from "@app/hooks/api/organization/queries";
import { fetchMyPrivateKey } from "@app/hooks/api/users/queries"; import { fetchMyPrivateKey } from "@app/hooks/api/users/queries";
import { navigateUserToOrg, navigateUserToSelectOrg } from "../../Login.utils"; import { navigateUserToOrg, useNavigateToSelectOrganization } from "../../Login.utils";
type Props = { type Props = {
providerAuthToken: string; providerAuthToken: string;
@@ -39,8 +39,11 @@ export const PasswordStep = ({
const { mutateAsync: selectOrganization } = useSelectOrganization(); const { mutateAsync: selectOrganization } = useSelectOrganization();
const { mutateAsync: oauthTokenExchange } = useOauthTokenExchange(); const { mutateAsync: oauthTokenExchange } = useOauthTokenExchange();
const { callbackPort, organizationId, hasExchangedPrivateKey } = const { navigateToSelectOrganization } = useNavigateToSelectOrganization();
jwt_decode(providerAuthToken) as any;
const { callbackPort, organizationId, hasExchangedPrivateKey } = jwt_decode(
providerAuthToken
) as any;
const handleExchange = async () => { const handleExchange = async () => {
try { try {
@@ -92,7 +95,7 @@ export const PasswordStep = ({
// case: user has orgs, so we navigate the user to select an org // case: user has orgs, so we navigate the user to select an org
if (userOrgs.length > 0) { if (userOrgs.length > 0) {
navigateUserToSelectOrg(router, callbackPort); navigateToSelectOrganization(callbackPort);
} }
// case: no orgs found, so we navigate the user to create an org // case: no orgs found, so we navigate the user to create an org
else { else {
@@ -176,7 +179,7 @@ export const PasswordStep = ({
// case: user has orgs, so we navigate the user to select an org // case: user has orgs, so we navigate the user to select an org
if (userOrgs.length > 0) { if (userOrgs.length > 0) {
navigateUserToSelectOrg(router, callbackPort); navigateToSelectOrganization(callbackPort);
} }
// case: no orgs found, so we navigate the user to create an org // case: no orgs found, so we navigate the user to create an org
else { else {
@@ -220,7 +223,7 @@ export const PasswordStep = ({
const userOrgs = await fetchOrganizations(); const userOrgs = await fetchOrganizations();
if (userOrgs.length > 0) { if (userOrgs.length > 0) {
navigateUserToSelectOrg(router); navigateToSelectOrganization();
} else { } else {
await navigateUserToOrg(router); await navigateUserToOrg(router);
} }
@@ -270,7 +273,7 @@ export const PasswordStep = ({
<form onSubmit={handleLogin} className="mx-auto h-full w-full max-w-md px-6 pt-8"> <form onSubmit={handleLogin} className="mx-auto h-full w-full max-w-md px-6 pt-8">
<div className="mb-8"> <div className="mb-8">
<p className="mx-auto mb-4 flex w-max justify-center bg-gradient-to-b from-white to-bunker-200 bg-clip-text text-center text-xl font-medium text-transparent"> <p className="mx-auto mb-4 flex w-max justify-center bg-gradient-to-b from-white to-bunker-200 bg-clip-text text-center text-xl font-medium text-transparent">
What&apos;s your Infisical password? What&apos;s your Infisical password?
</p> </p>
</div> </div>
<div className="relative mx-auto flex max-h-24 w-1/4 w-full min-w-[22rem] items-center justify-center rounded-lg md:max-h-28 lg:w-1/6"> <div className="relative mx-auto flex max-h-24 w-1/4 w-full min-w-[22rem] items-center justify-center rounded-lg md:max-h-28 lg:w-1/6">