diff --git a/frontend/src/pages/organization/AccessManagementPage/components/OrgIdentityTab/components/IdentitySection/IdentityModal.tsx b/frontend/src/pages/organization/AccessManagementPage/components/OrgIdentityTab/components/IdentitySection/IdentityModal.tsx index 829b55674..1d080be7d 100644 --- a/frontend/src/pages/organization/AccessManagementPage/components/OrgIdentityTab/components/IdentitySection/IdentityModal.tsx +++ b/frontend/src/pages/organization/AccessManagementPage/components/OrgIdentityTab/components/IdentitySection/IdentityModal.tsx @@ -148,7 +148,11 @@ export const IdentityModal = ({ popUp, handlePopUpToggle }: Props) => { accessTokenTTL: 2592000, accessTokenMaxTTL: 2592000, accessTokenNumUsesLimit: 0, - accessTokenPeriod: 0 + accessTokenPeriod: 0, + lockoutEnabled: true, + lockoutThreshold: 3, + lockoutDuration: 300, + lockoutCounterReset: 30 }); handlePopUpToggle("identity", false); diff --git a/frontend/src/pages/organization/AccessManagementPage/components/OrgIdentityTab/components/IdentitySection/IdentityUniversalAuthForm.tsx b/frontend/src/pages/organization/AccessManagementPage/components/OrgIdentityTab/components/IdentitySection/IdentityUniversalAuthForm.tsx index c8d424e47..4a2802e08 100644 --- a/frontend/src/pages/organization/AccessManagementPage/components/OrgIdentityTab/components/IdentitySection/IdentityUniversalAuthForm.tsx +++ b/frontend/src/pages/organization/AccessManagementPage/components/OrgIdentityTab/components/IdentitySection/IdentityUniversalAuthForm.tsx @@ -20,6 +20,7 @@ import { Tabs } from "@app/components/v2"; import { useOrganization, useSubscription } from "@app/context"; +import { durationToSeconds, getObjectFromSeconds } from "@app/helpers/datetime"; import { useAddIdentityUniversalAuth, useGetIdentityUniversalAuth, @@ -29,7 +30,6 @@ import { IdentityTrustedIp } from "@app/hooks/api/identities/types"; import { UsePopUpState } from "@app/hooks/usePopUp"; import { IdentityFormTab } from "./types"; -import { durationToSeconds, getObjectFromSeconds } from "@app/helpers/datetime"; const schema = z .object({ @@ -96,7 +96,7 @@ const schema = z let isAnyParseError = false; const parsedLockoutDuration = parseInt(lockoutDurationValue, 10); - if (isNaN(parsedLockoutDuration)) { + if (Number.isNaN(parsedLockoutDuration)) { ctx.addIssue({ code: z.ZodIssueCode.custom, message: "Lockout duration must be a number", @@ -106,7 +106,7 @@ const schema = z } const parsedLockoutCounterReset = parseInt(lockoutCounterResetValue, 10); - if (isNaN(parsedLockoutCounterReset)) { + if (Number.isNaN(parsedLockoutCounterReset)) { ctx.addIssue({ code: z.ZodIssueCode.custom, message: "Lockout counter reset must be a number", @@ -195,12 +195,12 @@ export const IdentityUniversalAuthForm = ({ const accessTokenPeriodValue = Number(watch("accessTokenPeriod")); - const lockoutEnabled = watch("lockoutEnabled"); - const lockoutThreshold = watch("lockoutThreshold"); - const lockoutDurationValue = watch("lockoutDurationValue"); - const lockoutDurationUnit = watch("lockoutDurationUnit"); - const lockoutCounterResetValue = watch("lockoutCounterResetValue"); - const lockoutCounterResetUnit = watch("lockoutCounterResetUnit"); + const lockoutEnabledWatch = watch("lockoutEnabled"); + const lockoutThresholdWatch = watch("lockoutThreshold"); + const lockoutDurationValueWatch = watch("lockoutDurationValue"); + const lockoutDurationUnitWatch = watch("lockoutDurationUnit"); + const lockoutCounterResetValueWatch = watch("lockoutCounterResetValue"); + const lockoutCounterResetUnitWatch = watch("lockoutCounterResetUnit"); const { fields: clientSecretTrustedIpsFields, @@ -341,20 +341,25 @@ export const IdentityUniversalAuthForm = ({ return (
{ - setTabValue( - ["accessTokenTrustedIps", "clientSecretTrustedIps"].includes(Object.keys(fields)[0]) - ? IdentityFormTab.Advanced - : [ - "lockoutEnabled", - "lockoutThreshold", - "lockoutDurationValue", - "lockoutDurationUnit", - "lockoutCounterResetValue", - "lockoutCounterResetUnit" - ].includes(Object.keys(fields)[0]) - ? IdentityFormTab.Lockout - : IdentityFormTab.Configuration - ); + const firstErrorField = Object.keys(fields)[0]; + let tab = IdentityFormTab.Configuration; + + if (["accessTokenTrustedIps", "clientSecretTrustedIps"].includes(firstErrorField)) { + tab = IdentityFormTab.Advanced; + } else if ( + [ + "lockoutEnabled", + "lockoutThreshold", + "lockoutDurationValue", + "lockoutDurationUnit", + "lockoutCounterResetValue", + "lockoutCounterResetUnit" + ].includes(firstErrorField) + ) { + tab = IdentityFormTab.Lockout; + } + + setTabValue(tab); })} > setTabValue(value as IdentityFormTab)}> @@ -435,11 +440,11 @@ export const IdentityUniversalAuthForm = ({ { return ( @@ -464,7 +469,7 @@ export const IdentityUniversalAuthForm = ({ render={({ field, fieldState: { error } }) => { return ( ); @@ -486,7 +491,7 @@ export const IdentityUniversalAuthForm = ({ render={({ field, fieldState: { error } }) => { return ( ); @@ -506,12 +511,12 @@ export const IdentityUniversalAuthForm = ({ name="lockoutDurationUnit" render={({ field, fieldState: { error } }) => ( clearLockouts()} isLoading={isClearLockoutsPending} colorSchema="secondary" > diff --git a/frontend/src/pages/organization/SecretSharingSettingsPage/components/OrgSecretShareLimitSection/OrgSecretShareLimitSection.tsx b/frontend/src/pages/organization/SecretSharingSettingsPage/components/OrgSecretShareLimitSection/OrgSecretShareLimitSection.tsx index 71d133d2e..b3e4976f3 100644 --- a/frontend/src/pages/organization/SecretSharingSettingsPage/components/OrgSecretShareLimitSection/OrgSecretShareLimitSection.tsx +++ b/frontend/src/pages/organization/SecretSharingSettingsPage/components/OrgSecretShareLimitSection/OrgSecretShareLimitSection.tsx @@ -7,8 +7,8 @@ import { createNotification } from "@app/components/notifications"; import { OrgPermissionCan } from "@app/components/permissions"; import { Button, FormControl, Input, Select, SelectItem } from "@app/components/v2"; import { OrgPermissionActions, OrgPermissionSubjects, useOrganization } from "@app/context"; -import { useUpdateOrg } from "@app/hooks/api"; import { durationToSeconds, getObjectFromSeconds } from "@app/helpers/datetime"; +import { useUpdateOrg } from "@app/hooks/api"; const MAX_SHARED_SECRET_LIFETIME_SECONDS = 30 * 24 * 60 * 60; // 30 days in seconds const MIN_SHARED_SECRET_LIFETIME_SECONDS = 5 * 60; // 5 minutes in seconds