fix: enhance authorization token capture logic based on checkout feature status

This commit is contained in:
claudi 2026-03-04 12:56:49 +01:00
parent 308f77f84e
commit 695182c44f
2 changed files with 19 additions and 12 deletions

View file

@ -17,8 +17,10 @@
var listenerPatchActive = true; var listenerPatchActive = true;
var dragHandlerInstalled = false; var dragHandlerInstalled = false;
// Capture Authorization token from XHR requests // Capture Authorization token from XHR requests (only if checkout is enabled)
window.capturedAuthToken = null; window.capturedAuthToken = null;
if (window.webdropConfig && window.webdropConfig.enableCheckout) {
console.log('[Intercept] Auth token capture enabled (checkout feature active)');
var originalXHRSetRequestHeader = XMLHttpRequest.prototype.setRequestHeader; var originalXHRSetRequestHeader = XMLHttpRequest.prototype.setRequestHeader;
XMLHttpRequest.prototype.setRequestHeader = function(header, value) { XMLHttpRequest.prototype.setRequestHeader = function(header, value) {
if (header === 'Authorization' && value.startsWith('Bearer ')) { if (header === 'Authorization' && value.startsWith('Bearer ')) {
@ -27,6 +29,9 @@
} }
return originalXHRSetRequestHeader.apply(this, arguments); return originalXHRSetRequestHeader.apply(this, arguments);
}; };
} else {
console.log('[Intercept] Auth token capture disabled (checkout feature inactive)');
}
// ============================================================================ // ============================================================================
// PART 1: Intercept Angular's dragstart listener registration // PART 1: Intercept Angular's dragstart listener registration

View file

@ -667,10 +667,11 @@ class MainWindow(QMainWindow):
logger.debug(f" [{i+1}] {m['url_prefix']} -> {m['local_path']}") logger.debug(f" [{i+1}] {m['url_prefix']} -> {m['local_path']}")
# Generate config object as JSON # Generate config object as JSON
config_obj = {"urlMappings": mappings} config_obj = {"urlMappings": mappings, "enableCheckout": self.config.enable_checkout}
config_json = json.dumps(config_obj) config_json = json.dumps(config_obj)
logger.debug(f"Config JSON size: {len(config_json)} bytes") logger.debug(f"Config JSON size: {len(config_json)} bytes")
logger.debug(f"Checkout enabled: {self.config.enable_checkout}")
# Generate JavaScript code - Safe injection with error handling # Generate JavaScript code - Safe injection with error handling
config_js = f""" config_js = f"""
@ -680,6 +681,7 @@ class MainWindow(QMainWindow):
console.log('[WebDrop Config] Starting configuration injection...'); console.log('[WebDrop Config] Starting configuration injection...');
window.webdropConfig = {config_json}; window.webdropConfig = {config_json};
console.log('[WebDrop Config] Configuration object created'); console.log('[WebDrop Config] Configuration object created');
console.log('[WebDrop Config] Checkout enabled: ' + window.webdropConfig.enableCheckout);
if (window.webdropConfig && window.webdropConfig.urlMappings) {{ if (window.webdropConfig && window.webdropConfig.urlMappings) {{
console.log('[WebDrop Config] SUCCESS: ' + window.webdropConfig.urlMappings.length + ' URL mappings loaded'); console.log('[WebDrop Config] SUCCESS: ' + window.webdropConfig.urlMappings.length + ' URL mappings loaded');