mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-08 07:27:43 +00:00
Improvement: Use select organization hook
This commit is contained in:
@@ -12,7 +12,7 @@ import attemptLoginMfa from "@app/components/utilities/attemptLoginMfa";
|
|||||||
import { Button } from "@app/components/v2";
|
import { Button } from "@app/components/v2";
|
||||||
import { useUpdateUserAuthMethods } from "@app/hooks/api";
|
import { useUpdateUserAuthMethods } from "@app/hooks/api";
|
||||||
import { useSendMfaToken } from "@app/hooks/api/auth";
|
import { useSendMfaToken } from "@app/hooks/api/auth";
|
||||||
import { selectOrganization } from "@app/hooks/api/auth/queries";
|
import { useSelectOrganization } from "@app/hooks/api/auth/queries";
|
||||||
import { fetchOrganizations } from "@app/hooks/api/organization/queries";
|
import { fetchOrganizations } from "@app/hooks/api/organization/queries";
|
||||||
import { fetchUserDetails } from "@app/hooks/api/users/queries";
|
import { fetchUserDetails } from "@app/hooks/api/users/queries";
|
||||||
import { AuthMethod } from "@app/hooks/api/users/types";
|
import { AuthMethod } from "@app/hooks/api/users/types";
|
||||||
@@ -70,6 +70,7 @@ export const MFAStep = ({ email, password, providerAuthToken }: Props) => {
|
|||||||
|
|
||||||
const sendMfaToken = useSendMfaToken();
|
const sendMfaToken = useSendMfaToken();
|
||||||
const { mutateAsync: updateUserAuthMethodsMutateAsync } = useUpdateUserAuthMethods();
|
const { mutateAsync: updateUserAuthMethodsMutateAsync } = useUpdateUserAuthMethods();
|
||||||
|
const { mutateAsync: selectOrganization } = useSelectOrganization();
|
||||||
|
|
||||||
const handleLoginMfa = async () => {
|
const handleLoginMfa = async () => {
|
||||||
try {
|
try {
|
||||||
@@ -116,11 +117,6 @@ export const MFAStep = ({ email, password, providerAuthToken }: Props) => {
|
|||||||
if (organizationId) {
|
if (organizationId) {
|
||||||
const { token: newJwtToken } = await selectOrganization({ organizationId });
|
const { token: newJwtToken } = await selectOrganization({ organizationId });
|
||||||
|
|
||||||
console.log(
|
|
||||||
"organization id was present. new JWT token to be used in CLI:",
|
|
||||||
newJwtToken
|
|
||||||
);
|
|
||||||
|
|
||||||
const instance = axios.create();
|
const instance = axios.create();
|
||||||
await instance.post(cliUrl, {
|
await instance.post(cliUrl, {
|
||||||
...isCliLoginSuccessful.loginResponse,
|
...isCliLoginSuccessful.loginResponse,
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import attemptCliLogin from "@app/components/utilities/attemptCliLogin";
|
|||||||
import attemptLogin from "@app/components/utilities/attemptLogin";
|
import attemptLogin from "@app/components/utilities/attemptLogin";
|
||||||
import { Button, Input } from "@app/components/v2";
|
import { Button, Input } from "@app/components/v2";
|
||||||
import { useUpdateUserAuthMethods } from "@app/hooks/api";
|
import { useUpdateUserAuthMethods } from "@app/hooks/api";
|
||||||
import { selectOrganization } from "@app/hooks/api/auth/queries";
|
import { useSelectOrganization } from "@app/hooks/api/auth/queries";
|
||||||
import { fetchOrganizations } from "@app/hooks/api/organization/queries";
|
import { fetchOrganizations } from "@app/hooks/api/organization/queries";
|
||||||
import { fetchUserDetails } from "@app/hooks/api/users/queries";
|
import { fetchUserDetails } from "@app/hooks/api/users/queries";
|
||||||
|
|
||||||
@@ -36,6 +36,7 @@ export const PasswordStep = ({
|
|||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const { mutateAsync } = useUpdateUserAuthMethods();
|
const { mutateAsync } = useUpdateUserAuthMethods();
|
||||||
|
const { mutateAsync: selectOrganization } = useSelectOrganization();
|
||||||
|
|
||||||
const { callbackPort, isLinkingRequired, authMethod, organizationId } = jwt_decode(
|
const { callbackPort, isLinkingRequired, authMethod, organizationId } = jwt_decode(
|
||||||
providerAuthToken
|
providerAuthToken
|
||||||
|
|||||||
Reference in New Issue
Block a user