mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-08 22:28:15 +00:00
misc: addressed ux issues
This commit is contained in:
@@ -288,7 +288,6 @@ export const registerSsoRouter = async (server: FastifyZodProvider) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
return {
|
return {
|
||||||
mfaEnabled: false,
|
|
||||||
encryptionVersion: data.user.encryptionVersion,
|
encryptionVersion: data.user.encryptionVersion,
|
||||||
token: data.token.access,
|
token: data.token.access,
|
||||||
publicKey: data.user.publicKey,
|
publicKey: data.user.publicKey,
|
||||||
|
|||||||
@@ -95,7 +95,6 @@ export const registerLoginRouter = async (server: FastifyZodProvider) => {
|
|||||||
}),
|
}),
|
||||||
response: {
|
response: {
|
||||||
200: z.object({
|
200: z.object({
|
||||||
mfaEnabled: z.literal(false),
|
|
||||||
encryptionVersion: z.number().default(1).nullable().optional(),
|
encryptionVersion: z.number().default(1).nullable().optional(),
|
||||||
protectedKey: z.string().nullable(),
|
protectedKey: z.string().nullable(),
|
||||||
protectedKeyIV: z.string().nullable(),
|
protectedKeyIV: z.string().nullable(),
|
||||||
@@ -131,7 +130,6 @@ export const registerLoginRouter = async (server: FastifyZodProvider) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
return {
|
return {
|
||||||
mfaEnabled: false,
|
|
||||||
encryptionVersion: data.user.encryptionVersion,
|
encryptionVersion: data.user.encryptionVersion,
|
||||||
token: data.token.access,
|
token: data.token.access,
|
||||||
publicKey: data.user.publicKey,
|
publicKey: data.user.publicKey,
|
||||||
|
|||||||
@@ -46,6 +46,7 @@ export default function LoginPage() {
|
|||||||
const selectOrg = useSelectOrganization();
|
const selectOrg = useSelectOrganization();
|
||||||
const { data: user, isLoading: userLoading } = useGetUser();
|
const { data: user, isLoading: userLoading } = useGetUser();
|
||||||
const [shouldShowMfa, toggleShowMfa] = useToggle(false);
|
const [shouldShowMfa, toggleShowMfa] = useToggle(false);
|
||||||
|
const [isInitialOrgCheckLoading, setIsInitialOrgCheckLoading] = useState(true);
|
||||||
|
|
||||||
const [mfaSuccessCallback, setMfaSuccessCallback] = useState<() => void>(() => {});
|
const [mfaSuccessCallback, setMfaSuccessCallback] = useState<() => void>(() => {});
|
||||||
|
|
||||||
@@ -169,19 +170,22 @@ export default function LoginPage() {
|
|||||||
}
|
}
|
||||||
}, [router]);
|
}, [router]);
|
||||||
|
|
||||||
// Case: User has no organizations.
|
|
||||||
// This can happen if the user was previously a member, but the organization was deleted or the user was removed.
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (organizations.isLoading || !organizations.data) return;
|
if (organizations.isLoading || !organizations.data) return;
|
||||||
|
|
||||||
|
// Case: User has no organizations.
|
||||||
|
// This can happen if the user was previously a member, but the organization was deleted or the user was removed.
|
||||||
if (organizations.data.length === 0) {
|
if (organizations.data.length === 0) {
|
||||||
router.push("/org/none");
|
router.push("/org/none");
|
||||||
} else if (organizations.data.length === 1) {
|
} else if (organizations.data.length === 1) {
|
||||||
if (callbackPort) {
|
if (callbackPort) {
|
||||||
handleCliRedirect();
|
handleCliRedirect();
|
||||||
|
setIsInitialOrgCheckLoading(false);
|
||||||
} else {
|
} else {
|
||||||
handleSelectOrganization(organizations.data[0]);
|
handleSelectOrganization(organizations.data[0]);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
setIsInitialOrgCheckLoading(false);
|
||||||
}
|
}
|
||||||
}, [organizations.isLoading, organizations.data]);
|
}, [organizations.isLoading, organizations.data]);
|
||||||
|
|
||||||
@@ -191,7 +195,11 @@ export default function LoginPage() {
|
|||||||
}
|
}
|
||||||
}, [defaultSelectedOrg]);
|
}, [defaultSelectedOrg]);
|
||||||
|
|
||||||
if (userLoading || !user) {
|
if (
|
||||||
|
userLoading ||
|
||||||
|
!user ||
|
||||||
|
((isInitialOrgCheckLoading || defaultSelectedOrg) && !shouldShowMfa)
|
||||||
|
) {
|
||||||
return <LoadingScreen />;
|
return <LoadingScreen />;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -205,11 +213,7 @@ export default function LoginPage() {
|
|||||||
<meta name="og:description" content={t("login.og-description") ?? ""} />
|
<meta name="og:description" content={t("login.og-description") ?? ""} />
|
||||||
</Head>
|
</Head>
|
||||||
{shouldShowMfa ? (
|
{shouldShowMfa ? (
|
||||||
<Mfa
|
<Mfa email={user.email as string} successCallback={mfaSuccessCallback} />
|
||||||
email={user.email as string}
|
|
||||||
successCallback={mfaSuccessCallback}
|
|
||||||
closeMfa={() => toggleShowMfa.off()}
|
|
||||||
/>
|
|
||||||
) : (
|
) : (
|
||||||
<div className="mx-auto mt-20 w-fit rounded-lg border-2 border-mineshaft-500 p-10 shadow-lg">
|
<div className="mx-auto mt-20 w-fit rounded-lg border-2 border-mineshaft-500 p-10 shadow-lg">
|
||||||
<Link href="/">
|
<Link href="/">
|
||||||
|
|||||||
@@ -32,8 +32,8 @@ const codeInputProps = {
|
|||||||
} as const;
|
} as const;
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
successCallback: () => void;
|
successCallback: () => void | Promise<void>;
|
||||||
closeMfa: () => void;
|
closeMfa?: () => void;
|
||||||
hideLogo?: boolean;
|
hideLogo?: boolean;
|
||||||
email: string;
|
email: string;
|
||||||
};
|
};
|
||||||
@@ -58,8 +58,10 @@ export const Mfa = ({ successCallback, closeMfa, hideLogo, email }: Props) => {
|
|||||||
SecurityClient.setMfaToken("");
|
SecurityClient.setMfaToken("");
|
||||||
SecurityClient.setToken(token);
|
SecurityClient.setToken(token);
|
||||||
|
|
||||||
successCallback();
|
await successCallback();
|
||||||
closeMfa();
|
if (closeMfa) {
|
||||||
|
closeMfa();
|
||||||
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (triesLeft) {
|
if (triesLeft) {
|
||||||
setTriesLeft((left) => {
|
setTriesLeft((left) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user