        
                if (redirectParam) {
                    // Use the redirect parameter if it exists and is valid
                    const decodedRedirect = decodeURIComponent(redirectParam);
                    if (isValidRedirectUrl(decodedRedirect)) {
                        return decodedRedirect;
                    } else {
                        console.warn('Invalid redirect parameter blocked:', redirectParam);
                        // Fall through to check current params
               