Skip to content

Commit

Permalink
Fix ResetPassword form doesn't redirect to login page
Browse files Browse the repository at this point in the history
Closes Missing redirection after password reset #70
  • Loading branch information
fzaninotto committed Sep 2, 2024
1 parent 5d03488 commit 4df2c48
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion packages/ra-supabase-core/src/useResetPassword.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
import { OnError, OnSuccess, useAuthProvider, useNotify } from 'ra-core';
import {
OnError,
OnSuccess,
useAuthProvider,
useNotify,
useRedirect,
} from 'ra-core';
import { useMutation, UseMutationResult } from '@tanstack/react-query';
import { ResetPasswordParams, SupabaseAuthProvider } from './authProvider';

Expand Down Expand Up @@ -33,6 +39,7 @@ export const useResetPassword = (
UseMutationResult<unknown, Error, ResetPasswordParams>
] => {
const notify = useNotify();
const redirect = useRedirect();
const authProvider = useAuthProvider<SupabaseAuthProvider>();

if (authProvider == null) {
Expand All @@ -49,6 +56,7 @@ export const useResetPassword = (

const {
onSuccess = () => {
redirect('/login');
notify('ra-supabase.auth.password_reset', { type: 'info' });
},
onError = error => notify(error.message, { type: 'error' }),
Expand Down

0 comments on commit 4df2c48

Please sign in to comment.