diff --git a/src/app/auth/resource/[resourceId]/components/ResourceAuthPortal.tsx b/src/app/auth/resource/[resourceId]/components/ResourceAuthPortal.tsx index 87226e24..5fb0163d 100644 --- a/src/app/auth/resource/[resourceId]/components/ResourceAuthPortal.tsx +++ b/src/app/auth/resource/[resourceId]/components/ResourceAuthPortal.tsx @@ -64,11 +64,14 @@ type ResourceAuthPortalProps = { }; redirect: string; queryParamName: string; + numMethods: number; }; export default function ResourceAuthPortal(props: ResourceAuthPortalProps) { const router = useRouter(); + const numMethods = props.numMethods; + const [passwordError, setPasswordError] = useState(null); const [pincodeError, setPincodeError] = useState(null); const [accessDenied, setAccessDenied] = useState(false); @@ -90,16 +93,6 @@ export default function ResourceAuthPortal(props: ResourceAuthPortalProps) { const [activeTab, setActiveTab] = useState(getDefaultSelectedMethod()); - const getColLength = () => { - let colLength = 0; - if (props.methods.pincode) colLength++; - if (props.methods.password) colLength++; - if (props.methods.sso) colLength++; - return colLength; - }; - - const [numMethods, setNumMethods] = useState(getColLength()); - const pinForm = useForm>({ resolver: zodResolver(pinSchema), defaultValues: { @@ -125,9 +118,7 @@ export default function ResourceAuthPortal(props: ResourceAuthPortalProps) { setLoadingLogin(true); api.post>( `/resource/${props.resource.id}/auth/pincode`, - { - pincode: values.pin, - }, + { pincode: values.pin }, ) .then((res) => { const session = res.data.data.session; @@ -202,10 +193,17 @@ export default function ResourceAuthPortal(props: ResourceAuthPortalProps) { {numMethods > 1 && ( {props.methods.pincode && ( diff --git a/src/app/auth/resource/[resourceId]/page.tsx b/src/app/auth/resource/[resourceId]/page.tsx index 32b7d067..e3055b1a 100644 --- a/src/app/auth/resource/[resourceId]/page.tsx +++ b/src/app/auth/resource/[resourceId]/page.tsx @@ -80,6 +80,14 @@ export default async function ResourceAuthPage(props: { ); } + const getNumMethods = () => { + let colLength = 0; + if (authInfo.pincode) colLength++; + if (authInfo.password) colLength++; + if (authInfo.sso) colLength++; + return colLength; + }; + return ( <>
@@ -97,6 +105,7 @@ export default async function ResourceAuthPage(props: { queryParamName={ process.env.RESOURCE_SESSION_QUERY_PARAM_NAME! } + numMethods={getNumMethods()} />