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.
26 lines
545 B
TypeScript
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,
|
|
});
|
|
}
|