webContents.ts: Fix clearAuthCache invocation

The options were no propagated for the overload
with RemovePassword options
This commit is contained in:
softworkz
2025-11-09 02:33:51 +01:00
parent 4129cc17a6
commit 04210955a3
3 changed files with 44 additions and 8 deletions

View File

@@ -111,9 +111,29 @@ module.exports = (socket) => {
const browserWindow = getWindowById(id);
browserWindow.webContents.session.allowNTLMCredentialsForDomains(domains);
});
socket.on('webContents-session-clearAuthCache', async (id, guid) => {
const browserWindow = getWindowById(id);
await browserWindow.webContents.session.clearAuthCache();
socket.on('webContents-session-clearAuthCache', async (...args) => {
// Overload support: (id, guid) OR (id, options, guid)
const browserWindow = getWindowById(args[0]);
let guid;
if (args.length === 2) {
// No options
guid = args[1];
await browserWindow.webContents.session.clearAuthCache();
}
else if (args.length === 3) {
const options = args[1];
guid = args[2];
try {
await browserWindow.webContents.session.clearAuthCache(options);
}
catch {
// Fallback to clearing without options if Electron version rejects custom options
await browserWindow.webContents.session.clearAuthCache();
}
}
else {
return; // invalid invocation
}
electronSocket.emit('webContents-session-clearAuthCache-completed' + guid);
});
socket.on('webContents-session-clearCache', async (id, guid) => {

File diff suppressed because one or more lines are too long

View File

@@ -137,10 +137,26 @@ export = (socket: Socket) => {
browserWindow.webContents.session.allowNTLMCredentialsForDomains(domains);
});
socket.on('webContents-session-clearAuthCache', async (id, guid) => {
const browserWindow = getWindowById(id);
await browserWindow.webContents.session.clearAuthCache();
socket.on('webContents-session-clearAuthCache', async (...args) => {
// Overload support: (id, guid) OR (id, options, guid)
const browserWindow = getWindowById(args[0]);
let guid: string;
if (args.length ===2) {
// No options
guid = args[1];
await browserWindow.webContents.session.clearAuthCache();
} else if (args.length ===3) {
const options = args[1];
guid = args[2];
try {
await browserWindow.webContents.session.clearAuthCache(options);
} catch {
// Fallback to clearing without options if Electron version rejects custom options
await browserWindow.webContents.session.clearAuthCache();
}
} else {
return; // invalid invocation
}
electronSocket.emit('webContents-session-clearAuthCache-completed' + guid);
});