Files
myeasycms-v2/packages/supabase/src/hooks/use-fetch-mfa-factors.ts
gbuomprisco f15e92a306 Adjust MFA factor fetching and verification process
This commit refines the Multi-Factor Authentication (MFA) handling by removing 'requireUser' method, optimizing 'useFetchMfaFactors' hook to avoid fetching stale data, and improving error logging. The changes enhance the system's user session management and the MFA challenge response, ensuring smoother user experience and potential troubleshooting.
2024-06-17 12:30:20 +08:00

26 lines
545 B
TypeScript

import { useQuery } from '@tanstack/react-query';
import { useSupabase } from './use-supabase';
import { useFactorsMutationKey } from './use-user-factors-mutation-key';
export function useFetchAuthFactors(userId: string) {
const client = useSupabase();
const queryKey = useFactorsMutationKey(userId);
const queryFn = async () => {
const { data, error } = await client.auth.mfa.listFactors();
if (error) {
throw error;
}
return data;
};
return useQuery({
queryKey,
queryFn,
staleTime: 0,
});
}