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 dragHandlerInstalled = false;
|
||||
|
||||
// Capture Authorization token from XHR requests
|
||||
// Capture Authorization token from XHR requests (only if checkout is enabled)
|
||||
window.capturedAuthToken = null;
|
||||
var originalXHRSetRequestHeader = XMLHttpRequest.prototype.setRequestHeader;
|
||||
XMLHttpRequest.prototype.setRequestHeader = function(header, value) {
|
||||
if (header === 'Authorization' && value.startsWith('Bearer ')) {
|
||||
window.capturedAuthToken = value;
|
||||
console.log('[Intercept] Captured auth token');
|
||||
}
|
||||
return originalXHRSetRequestHeader.apply(this, arguments);
|
||||
};
|
||||
if (window.webdropConfig && window.webdropConfig.enableCheckout) {
|
||||
console.log('[Intercept] Auth token capture enabled (checkout feature active)');
|
||||
var originalXHRSetRequestHeader = XMLHttpRequest.prototype.setRequestHeader;
|
||||
XMLHttpRequest.prototype.setRequestHeader = function(header, value) {
|
||||
if (header === 'Authorization' && value.startsWith('Bearer ')) {
|
||||
window.capturedAuthToken = value;
|
||||
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
|
||||
|
|
|
|||
|
|
@ -667,10 +667,11 @@ class MainWindow(QMainWindow):
|
|||
logger.debug(f" [{i+1}] {m['url_prefix']} -> {m['local_path']}")
|
||||
|
||||
# Generate config object as JSON
|
||||
config_obj = {"urlMappings": mappings}
|
||||
config_obj = {"urlMappings": mappings, "enableCheckout": self.config.enable_checkout}
|
||||
config_json = json.dumps(config_obj)
|
||||
|
||||
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
|
||||
config_js = f"""
|
||||
|
|
@ -680,6 +681,7 @@ class MainWindow(QMainWindow):
|
|||
console.log('[WebDrop Config] Starting configuration injection...');
|
||||
window.webdropConfig = {config_json};
|
||||
console.log('[WebDrop Config] Configuration object created');
|
||||
console.log('[WebDrop Config] Checkout enabled: ' + window.webdropConfig.enableCheckout);
|
||||
|
||||
if (window.webdropConfig && window.webdropConfig.urlMappings) {{
|
||||
console.log('[WebDrop Config] SUCCESS: ' + window.webdropConfig.urlMappings.length + ' URL mappings loaded');
|
||||
|
|
@ -1335,11 +1337,11 @@ class MainWindow(QMainWindow):
|
|||
sessions. Also disconnects and reconnects the page to ensure clean state.
|
||||
"""
|
||||
logger.info("Clearing cache and cookies")
|
||||
|
||||
|
||||
try:
|
||||
# Clear cache and cookies in the web view profile
|
||||
self.web_view.clear_cache_and_cookies()
|
||||
|
||||
|
||||
# Show confirmation message
|
||||
QMessageBox.information(
|
||||
self,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue