mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-08 12:28:54 +00:00
Fix redirect issue on locked users, improve lockout message
This commit is contained in:
@@ -5,6 +5,7 @@ import { t } from "i18next";
|
|||||||
|
|
||||||
import Error from "@app/components/basic/Error";
|
import Error from "@app/components/basic/Error";
|
||||||
import TotpRegistration from "@app/components/mfa/TotpRegistration";
|
import TotpRegistration from "@app/components/mfa/TotpRegistration";
|
||||||
|
import { createNotification } from "@app/components/notifications";
|
||||||
import SecurityClient from "@app/components/utilities/SecurityClient";
|
import SecurityClient from "@app/components/utilities/SecurityClient";
|
||||||
import { Button, Tooltip } from "@app/components/v2";
|
import { Button, Tooltip } from "@app/components/v2";
|
||||||
import { isInfisicalCloud } from "@app/helpers/platform";
|
import { isInfisicalCloud } from "@app/helpers/platform";
|
||||||
@@ -121,6 +122,10 @@ export const Mfa = ({ successCallback, closeMfa, hideLogo, email, method }: Prop
|
|||||||
const newTriesLeft = triesLeft - 1;
|
const newTriesLeft = triesLeft - 1;
|
||||||
setTriesLeft(newTriesLeft);
|
setTriesLeft(newTriesLeft);
|
||||||
if (newTriesLeft <= 0) {
|
if (newTriesLeft <= 0) {
|
||||||
|
createNotification({
|
||||||
|
text: "User is temporary locked due to multiple failed login attempts. Try again after 5 minutes. You can also reset your password now to proceed.",
|
||||||
|
type: "error"
|
||||||
|
});
|
||||||
setIsLoading(false);
|
setIsLoading(false);
|
||||||
SecurityClient.setMfaToken("");
|
SecurityClient.setMfaToken("");
|
||||||
SecurityClient.setToken("");
|
SecurityClient.setToken("");
|
||||||
@@ -263,7 +268,7 @@ export const Mfa = ({ successCallback, closeMfa, hideLogo, email, method }: Prop
|
|||||||
colorSchema="primary"
|
colorSchema="primary"
|
||||||
variant="outline_bg"
|
variant="outline_bg"
|
||||||
isLoading={isLoading}
|
isLoading={isLoading}
|
||||||
isDisabled={!isCodeComplete}
|
isDisabled={!isCodeComplete || (typeof triesLeft === "number" && triesLeft <= 0)}
|
||||||
>
|
>
|
||||||
{String(t("mfa.verify"))}
|
{String(t("mfa.verify"))}
|
||||||
</Button>
|
</Button>
|
||||||
|
|||||||
@@ -117,12 +117,28 @@ export const SelectOrganizationSection = () => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const { token, isMfaEnabled, mfaMethod } = await selectOrg
|
let token;
|
||||||
.mutateAsync({
|
let isMfaEnabled;
|
||||||
|
let mfaMethod;
|
||||||
|
|
||||||
|
try {
|
||||||
|
const result = await selectOrg.mutateAsync({
|
||||||
organizationId: organization.id,
|
organizationId: organization.id,
|
||||||
userAgent: callbackPort ? UserAgentType.CLI : undefined
|
userAgent: callbackPort ? UserAgentType.CLI : undefined
|
||||||
})
|
});
|
||||||
.finally(() => setIsInitialOrgCheckLoading(false));
|
token = result.token;
|
||||||
|
isMfaEnabled = result.isMfaEnabled;
|
||||||
|
mfaMethod = result.mfaMethod;
|
||||||
|
} catch (error: any) {
|
||||||
|
setIsInitialOrgCheckLoading(false);
|
||||||
|
if (error?.response?.status === 403) {
|
||||||
|
await handleLogout();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
throw error;
|
||||||
|
} finally {
|
||||||
|
setIsInitialOrgCheckLoading(false);
|
||||||
|
}
|
||||||
|
|
||||||
await router.invalidate();
|
await router.invalidate();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user