Add user id parameter to multi-factor authentication functions
The multi-factor authentication functions have been modified to accept a user id as a parameter. This provides more flexibility as it allows a more specific targeting of users. The `useFetchAuthFactors` function has been updated to export the function rather than default, and the `useFactorsMutationKey` function has been updated to take a user id.
This commit is contained in:
@@ -3,9 +3,9 @@ import { useQuery } from '@tanstack/react-query';
|
||||
import { useSupabase } from './use-supabase';
|
||||
import { useFactorsMutationKey } from './use-user-factors-mutation-key';
|
||||
|
||||
function useFetchAuthFactors() {
|
||||
export function useFetchAuthFactors(userId: string) {
|
||||
const client = useSupabase();
|
||||
const queryKey = useFactorsMutationKey();
|
||||
const queryKey = useFactorsMutationKey(userId);
|
||||
|
||||
const queryFn = async () => {
|
||||
const { data, error } = await client.auth.mfa.listFactors();
|
||||
@@ -22,5 +22,3 @@ function useFetchAuthFactors() {
|
||||
queryFn,
|
||||
});
|
||||
}
|
||||
|
||||
export default useFetchAuthFactors;
|
||||
|
||||
@@ -1,8 +1,3 @@
|
||||
import { useUserSession } from './use-user-session';
|
||||
|
||||
export function useFactorsMutationKey() {
|
||||
const user = useUserSession();
|
||||
const userId = user?.data?.user.id;
|
||||
|
||||
export function useFactorsMutationKey(userId: string) {
|
||||
return ['mfa-factors', userId];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user