[英]How to handle incorrect proxy-auth credentials
I have an electron app that will sometimes be used behind corporate firewalls. 我有一个电子应用程序,有时会在公司防火墙后面使用。
I have added a login event listener to the app and requesting username and password from the user via a dialog box. 我已经向应用程序添加了登录事件监听器,并通过对话框从用户请求用户名和密码。
It's working fine if the user enters their details correctly the first time, but if there is an error with the first attempt and then the user enters the correct details the second time, the request seems to stall and then timeout. 如果用户第一次正确输入详细信息,则工作正常,但如果第一次尝试输入时出错,然后用户第二次输入正确的详细信息,则请求似乎停顿,然后超时。 If I activate another HTTP request, creating a third auth request, and enter the details correctly, it works.
如果我激活另一个HTTP请求,创建第三个身份验证请求并正确输入详细信息,则它可以工作。
Here is the code from the main process in it's current form: 这是当前流程中来自主流程的代码:
const requestHistory = [];
let onAuthCallback = function (username, password) {
const lastIndex = requestHistory.length - 1;
if (lastIndex < 0) {
return;
}
const {callback} = requestHistory[lastIndex];
callback(username, password);
};
app.on('login', (event, webContents, request, authInfo, callback) => {
event.preventDefault();
mainWindow.webContents.send('proxy-auth:req', authInfo);
requestHistory.push({event, webContents, request, authInfo, callback});
});
ipcMain.on('proxy-auth:userpass', (event, userpass) => {
console.info('userpass:', userpass);
const {username, password} = userpass;
try {
console.info('proxy-auth with "%s" "%s"', username, password);
onAuthCallback(username, password);
} catch (error) {
console.error('ERROR in `proxy-auth:userpass`:', error);
}
});
If anyone has any pointers that would be great. 如果有人有任何指针,那就太好了。 At the moment I'm thinking of just ignoring any second request to get this out quickly.
目前,我正在考虑忽略任何其他要求以快速实现这一目标。
Thanks 谢谢
So the answer is that there is currently a bug in Electron 答案是,Electron当前存在错误
https://github.com/electron/electron/issues/16010 https://github.com/electron/electron/issues/16010
That bug report has some suggestions to work around the problem. 该错误报告提供了一些解决该问题的建议。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.