mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-07 14:27:30 +00:00
misc: addressed signupinvite issue
This commit is contained in:
@@ -29,8 +29,10 @@ import {
|
|||||||
useSelectOrganization,
|
useSelectOrganization,
|
||||||
verifySignupInvite
|
verifySignupInvite
|
||||||
} from "@app/hooks/api/auth/queries";
|
} from "@app/hooks/api/auth/queries";
|
||||||
|
import { MfaMethod } from "@app/hooks/api/auth/types";
|
||||||
import { fetchOrganizations } from "@app/hooks/api/organization/queries";
|
import { fetchOrganizations } from "@app/hooks/api/organization/queries";
|
||||||
import { navigateUserToOrg } from "@app/views/Login/Login.utils";
|
import { navigateUserToOrg } from "@app/views/Login/Login.utils";
|
||||||
|
import { Mfa } from "@app/views/Login/Mfa";
|
||||||
|
|
||||||
// eslint-disable-next-line new-cap
|
// eslint-disable-next-line new-cap
|
||||||
const client = new jsrp.client();
|
const client = new jsrp.client();
|
||||||
@@ -59,6 +61,7 @@ export default function SignupInvite() {
|
|||||||
const [errors, setErrors] = useState<Errors>({});
|
const [errors, setErrors] = useState<Errors>({});
|
||||||
|
|
||||||
const [shouldShowMfa, toggleShowMfa] = useToggle(false);
|
const [shouldShowMfa, toggleShowMfa] = useToggle(false);
|
||||||
|
const [requiredMfaMethod, setRequiredMfaMethod] = useState(MfaMethod.EMAIL);
|
||||||
const [mfaSuccessCallback, setMfaSuccessCallback] = useState<() => void>(() => {});
|
const [mfaSuccessCallback, setMfaSuccessCallback] = useState<() => void>(() => {});
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const parsedUrl = queryString.parse(router.asPath.split("?")[1]);
|
const parsedUrl = queryString.parse(router.asPath.split("?")[1]);
|
||||||
@@ -184,12 +187,19 @@ export default function SignupInvite() {
|
|||||||
if (!orgId) throw new Error("You are not part of any organization");
|
if (!orgId) throw new Error("You are not part of any organization");
|
||||||
|
|
||||||
const completeSignupFlow = async () => {
|
const completeSignupFlow = async () => {
|
||||||
const { token: mfaToken, isMfaEnabled } = await selectOrganization({
|
const {
|
||||||
|
token: mfaToken,
|
||||||
|
isMfaEnabled,
|
||||||
|
mfaMethod
|
||||||
|
} = await selectOrganization({
|
||||||
organizationId: orgId
|
organizationId: orgId
|
||||||
});
|
});
|
||||||
|
|
||||||
if (isMfaEnabled) {
|
if (isMfaEnabled) {
|
||||||
SecurityClient.setMfaToken(mfaToken);
|
SecurityClient.setMfaToken(mfaToken);
|
||||||
|
if (mfaMethod) {
|
||||||
|
setRequiredMfaMethod(mfaMethod);
|
||||||
|
}
|
||||||
toggleShowMfa.on();
|
toggleShowMfa.on();
|
||||||
setMfaSuccessCallback(() => completeSignupFlow);
|
setMfaSuccessCallback(() => completeSignupFlow);
|
||||||
return;
|
return;
|
||||||
@@ -390,12 +400,23 @@ export default function SignupInvite() {
|
|||||||
<title>Sign Up</title>
|
<title>Sign Up</title>
|
||||||
<link rel="icon" href="/infisical.ico" />
|
<link rel="icon" href="/infisical.ico" />
|
||||||
</Head>
|
</Head>
|
||||||
<Link href="/">
|
{shouldShowMfa ? (
|
||||||
<div className="mb-4 mt-20 flex justify-center">
|
<Mfa
|
||||||
<Image src="/images/gradientLogo.svg" height={90} width={120} alt="Infisical Logo" />
|
email={email}
|
||||||
</div>
|
successCallback={mfaSuccessCallback}
|
||||||
</Link>
|
method={requiredMfaMethod}
|
||||||
{step === 1 ? stepConfirmEmail : step === 2 ? main : step4}
|
closeMfa={() => toggleShowMfa.off()}
|
||||||
|
/>
|
||||||
|
) : (
|
||||||
|
<>
|
||||||
|
<Link href="/">
|
||||||
|
<div className="mb-4 mt-20 flex justify-center">
|
||||||
|
<Image src="/images/gradientLogo.svg" height={90} width={120} alt="Infisical Logo" />
|
||||||
|
</div>
|
||||||
|
</Link>
|
||||||
|
{step === 1 ? stepConfirmEmail : step === 2 ? main : step4}
|
||||||
|
</>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -114,11 +114,7 @@ export const Mfa = ({ successCallback, closeMfa, hideLogo, email, method }: Prop
|
|||||||
<TotpRegistration
|
<TotpRegistration
|
||||||
onComplete={async () => {
|
onComplete={async () => {
|
||||||
setShouldShowTotpRegistration(false);
|
setShouldShowTotpRegistration(false);
|
||||||
|
|
||||||
await successCallback();
|
await successCallback();
|
||||||
if (closeMfa) {
|
|
||||||
closeMfa();
|
|
||||||
}
|
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -72,11 +72,11 @@ export const PasswordStep = ({ providerAuthToken, email, password, setPassword }
|
|||||||
|
|
||||||
if (isMfaEnabled) {
|
if (isMfaEnabled) {
|
||||||
SecurityClient.setMfaToken(token);
|
SecurityClient.setMfaToken(token);
|
||||||
|
setMfaSuccessCallback(() => finishWithOrgWorkflow);
|
||||||
if (mfaMethod) {
|
if (mfaMethod) {
|
||||||
setRequiredMfaMethod(mfaMethod);
|
setRequiredMfaMethod(mfaMethod);
|
||||||
}
|
}
|
||||||
toggleShowMfa.on();
|
toggleShowMfa.on();
|
||||||
setMfaSuccessCallback(() => finishWithOrgWorkflow);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user