fix: enhance authorization token capture logic based on checkout feature status
This commit is contained in:
parent
308f77f84e
commit
695182c44f
2 changed files with 19 additions and 12 deletions
|
|
@ -17,16 +17,21 @@
|
||||||
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;
|
||||||
var originalXHRSetRequestHeader = XMLHttpRequest.prototype.setRequestHeader;
|
if (window.webdropConfig && window.webdropConfig.enableCheckout) {
|
||||||
XMLHttpRequest.prototype.setRequestHeader = function(header, value) {
|
console.log('[Intercept] Auth token capture enabled (checkout feature active)');
|
||||||
if (header === 'Authorization' && value.startsWith('Bearer ')) {
|
var originalXHRSetRequestHeader = XMLHttpRequest.prototype.setRequestHeader;
|
||||||
window.capturedAuthToken = value;
|
XMLHttpRequest.prototype.setRequestHeader = function(header, value) {
|
||||||
console.log('[Intercept] Captured auth token');
|
if (header === 'Authorization' && value.startsWith('Bearer ')) {
|
||||||
}
|
window.capturedAuthToken = value;
|
||||||
return originalXHRSetRequestHeader.apply(this, arguments);
|
console.log('[Intercept] Captured auth token');
|
||||||
};
|
}
|
||||||
|
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
|
||||||
|
|
|
||||||
|
|
@ -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');
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue