Skip to content

Commit e2126a6

Browse files
committed
fix(Service Proxies): Fix proxy setting rehydration
1 parent 8405b09 commit e2126a6

3 files changed

Lines changed: 36 additions & 23 deletions

File tree

src/index.js

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -331,22 +331,7 @@ app.on('login', (event, webContents, request, authInfo, callback) => {
331331
debug('browser login event', authInfo);
332332
event.preventDefault();
333333

334-
if (authInfo.isProxy && authInfo.scheme === 'basic') {
335-
debug('Sending service echo ping');
336-
webContents.send('get-service-id');
337-
338-
ipcMain.once('service-id', (e, id) => {
339-
debug('Received service id', id);
340-
341-
const ps = proxySettings.get(id);
342-
if (ps) {
343-
debug('Sending proxy auth callback for service', id);
344-
callback(ps.user, ps.password);
345-
} else {
346-
debug('No proxy auth config found for', id);
347-
}
348-
});
349-
} else if (authInfo.scheme === 'basic') {
334+
if (!authInfo.isProxy && authInfo.scheme === 'basic') {
350335
debug('basic auth handler', authInfo);
351336
basicAuthHandler(mainWindow, authInfo);
352337
}

src/models/Service.js

Lines changed: 34 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -188,19 +188,24 @@ export default class Service {
188188
return userAgent;
189189
}
190190

191-
initializeWebViewEvents({ handleIPCMessage, openWindow }) {
191+
initializeWebViewEvents({ handleIPCMessage, openWindow, stores }) {
192+
const webContents = this.webview.getWebContents();
193+
192194
this.webview.addEventListener('ipc-message', e => handleIPCMessage({
193195
serviceId: this.id,
194196
channel: e.channel,
195197
args: e.args,
196198
}));
197199

198-
this.webview.addEventListener('new-window', (event, url, frameName, options) => openWindow({
199-
event,
200-
url,
201-
frameName,
202-
options,
203-
}));
200+
this.webview.addEventListener('new-window', (event, url, frameName, options) => {
201+
console.log('open window', event, url, frameName, options);
202+
openWindow({
203+
event,
204+
url,
205+
frameName,
206+
options,
207+
});
208+
});
204209

205210
this.webview.addEventListener('did-start-loading', (event) => {
206211
debug('Did start load', this.name, event);
@@ -234,6 +239,28 @@ export default class Service {
234239
debug('Service crashed', this.name);
235240
this.hasCrashed = true;
236241
});
242+
243+
webContents.on('login', (event, request, authInfo, callback) => {
244+
// const authCallback = callback;
245+
debug('browser login event', authInfo);
246+
event.preventDefault();
247+
248+
if (authInfo.isProxy && authInfo.scheme === 'basic') {
249+
debug('Sending service echo ping');
250+
webContents.send('get-service-id');
251+
252+
debug('Received service id', this.id);
253+
254+
const ps = stores.settings.proxy[this.id];
255+
256+
if (ps) {
257+
debug('Sending proxy auth callback for service', this.id);
258+
callback(ps.user, ps.password);
259+
} else {
260+
debug('No proxy auth config found for', this.id);
261+
}
262+
}
263+
});
237264
}
238265

239266
initializeWebViewListener() {

src/stores/ServicesStore.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,7 @@ export default class ServicesStore extends Store {
345345
service.initializeWebViewEvents({
346346
handleIPCMessage: this.actions.service.handleIPCMessage,
347347
openWindow: this.actions.service.openWindow,
348+
stores: this.stores,
348349
});
349350
service.initializeWebViewListener();
350351
}

0 commit comments

Comments
 (0)