Fix password update (#71)
* Fix password update * Use next or callback params for retro-compatibility
This commit is contained in:
committed by
GitHub
parent
2fe8fc0231
commit
25adc2d1e3
@@ -48,11 +48,12 @@ class AuthCallbackService {
|
||||
|
||||
const token_hash = searchParams.get('token_hash');
|
||||
const type = searchParams.get('type') as EmailOtpType | null;
|
||||
const callbackParam = searchParams.get('callback');
|
||||
const callbackParam = searchParams.get('next') ?? searchParams.get('callback');
|
||||
|
||||
let nextPath: string | null = null;
|
||||
const callbackUrl = callbackParam ? new URL(callbackParam) : null;
|
||||
|
||||
// if we have a callback url, we check if it has a next path
|
||||
if (callbackUrl) {
|
||||
// if we have a callback url, we check if it has a next path
|
||||
const callbackNextPath = callbackUrl.searchParams.get('next');
|
||||
|
||||
@@ -2,9 +2,10 @@ import { useMutation } from '@tanstack/react-query';
|
||||
|
||||
import { useSupabase } from './use-supabase';
|
||||
|
||||
interface Params {
|
||||
interface RequestPasswordResetMutationParams {
|
||||
email: string;
|
||||
redirectTo: string;
|
||||
captchaToken?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -18,11 +19,12 @@ export function useRequestResetPassword() {
|
||||
const client = useSupabase();
|
||||
const mutationKey = ['auth', 'reset-password'];
|
||||
|
||||
const mutationFn = async (params: Params) => {
|
||||
const mutationFn = async (params: RequestPasswordResetMutationParams) => {
|
||||
const { error, data } = await client.auth.resetPasswordForEmail(
|
||||
params.email,
|
||||
{
|
||||
redirectTo: params.redirectTo,
|
||||
captchaToken: params.captchaToken,
|
||||
},
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user