From 6cdb46ea4494838457f27ecc03256e9395d05ac7 Mon Sep 17 00:00:00 2001 From: gbuomprisco Date: Tue, 2 Jul 2024 11:46:19 +0800 Subject: [PATCH] Remove redundant 'next' parameter check in auth callback Refactored the condition handling for the next path in auth-callback.service.ts to only rely on the callbackUrl instead of an additional 'next' parameter. This not only simplifies the code but also reduces potential errors linked to multiple sources of truth for the next path direction. --- packages/supabase/src/auth-callback.service.ts | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/packages/supabase/src/auth-callback.service.ts b/packages/supabase/src/auth-callback.service.ts index dec133f88..1cefaf2e0 100644 --- a/packages/supabase/src/auth-callback.service.ts +++ b/packages/supabase/src/auth-callback.service.ts @@ -49,21 +49,19 @@ class AuthCallbackService { const token_hash = searchParams.get('token_hash'); const type = searchParams.get('type') as EmailOtpType | null; const callbackParam = searchParams.get('callback'); - const nextParam = searchParams.get('next'); let nextPath: string | null = null; const callbackUrl = callbackParam ? new URL(callbackParam) : null; - // if we have a next path in the query params, we use that - if (nextParam) { - nextPath = nextParam; - } else { + if (callbackUrl) { // if we have a callback url, we check if it has a next path - const callbackNextPath = callbackUrl ? callbackUrl.searchParams.get('next') : null; + const callbackNextPath = callbackUrl.searchParams.get('next'); // if we have a next path in the callback url, we use that if (callbackNextPath) { nextPath = callbackNextPath; + } else { + nextPath = callbackUrl.pathname; } }