mirror of
https://github.com/fosrl/pangolin.git
synced 2026-02-14 08:56:39 +00:00
move resource auth to auth router
This commit is contained in:
@@ -64,13 +64,20 @@ type ResourceAuthPortalProps = {
|
||||
};
|
||||
redirect: string;
|
||||
queryParamName: string;
|
||||
numMethods: number;
|
||||
};
|
||||
|
||||
export default function ResourceAuthPortal(props: ResourceAuthPortalProps) {
|
||||
const router = useRouter();
|
||||
|
||||
const numMethods = props.numMethods;
|
||||
const getNumMethods = () => {
|
||||
let colLength = 0;
|
||||
if (props.methods.pincode) colLength++;
|
||||
if (props.methods.password) colLength++;
|
||||
if (props.methods.sso) colLength++;
|
||||
return colLength;
|
||||
};
|
||||
|
||||
const [numMethods, setNumMethods] = useState(getNumMethods());
|
||||
|
||||
const [passwordError, setPasswordError] = useState<string | null>(null);
|
||||
const [pincodeError, setPincodeError] = useState<string | null>(null);
|
||||
@@ -117,7 +124,7 @@ export default function ResourceAuthPortal(props: ResourceAuthPortalProps) {
|
||||
const onPinSubmit = (values: z.infer<typeof pinSchema>) => {
|
||||
setLoadingLogin(true);
|
||||
api.post<AxiosResponse<AuthWithPasswordResponse>>(
|
||||
`/resource/${props.resource.id}/auth/pincode`,
|
||||
`/auth/resource/${props.resource.id}/pincode`,
|
||||
{ pincode: values.pin },
|
||||
)
|
||||
.then((res) => {
|
||||
@@ -141,7 +148,7 @@ export default function ResourceAuthPortal(props: ResourceAuthPortalProps) {
|
||||
const onPasswordSubmit = (values: z.infer<typeof passwordSchema>) => {
|
||||
setLoadingLogin(true);
|
||||
api.post<AxiosResponse<AuthWithPasswordResponse>>(
|
||||
`/resource/${props.resource.id}/auth/password`,
|
||||
`/auth/resource/${props.resource.id}/password`,
|
||||
{
|
||||
password: values.password,
|
||||
},
|
||||
|
||||
@@ -80,14 +80,6 @@ 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 (
|
||||
<>
|
||||
<div className="w-full max-w-md">
|
||||
@@ -105,7 +97,6 @@ export default async function ResourceAuthPage(props: {
|
||||
queryParamName={
|
||||
process.env.RESOURCE_SESSION_QUERY_PARAM_NAME!
|
||||
}
|
||||
numMethods={getNumMethods()}
|
||||
/>
|
||||
</div>
|
||||
</>
|
||||
|
||||
Reference in New Issue
Block a user