mirror of
https://github.com/bitwarden/browser.git
synced 2024-09-18 02:41:15 +02:00
check for chrome.webRequest.onAuthRequired
avail
This commit is contained in:
parent
1ea07a6ced
commit
a260d269ec
@ -230,69 +230,71 @@ var bg_isBackground = true,
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
chrome.webRequest.onAuthRequired.addListener(function (details, callback) {
|
if (chrome.webRequest && chrome.webRequest.onAuthRequired) {
|
||||||
if (!details.url || pendingAuthRequests.indexOf(details.requestId) != -1) {
|
chrome.webRequest.onAuthRequired.addListener(function (details, callback) {
|
||||||
if (callback) {
|
if (!details.url || pendingAuthRequests.indexOf(details.requestId) != -1) {
|
||||||
callback();
|
if (callback) {
|
||||||
|
callback();
|
||||||
|
}
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
var domain = bg_utilsService.getDomain(details.url);
|
var domain = bg_utilsService.getDomain(details.url);
|
||||||
if (!domain) {
|
if (!domain) {
|
||||||
if (callback) {
|
if (callback) {
|
||||||
callback();
|
callback();
|
||||||
|
}
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
pendingAuthRequests.push(details.requestId);
|
pendingAuthRequests.push(details.requestId);
|
||||||
|
|
||||||
if (bg_utilsService.isFirefox()) {
|
if (bg_utilsService.isFirefox()) {
|
||||||
return new Promise(function (resolve, reject) {
|
return new Promise(function (resolve, reject) {
|
||||||
|
bg_loginService.getAllDecryptedForDomain(domain).then(function (logins) {
|
||||||
|
if (!logins || logins.length !== 1) {
|
||||||
|
reject();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
resolve({
|
||||||
|
authCredentials: {
|
||||||
|
username: logins[0].username,
|
||||||
|
password: logins[0].password
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}, function () {
|
||||||
|
reject();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else {
|
||||||
bg_loginService.getAllDecryptedForDomain(domain).then(function (logins) {
|
bg_loginService.getAllDecryptedForDomain(domain).then(function (logins) {
|
||||||
if (!logins || logins.length !== 1) {
|
if (!logins || logins.length !== 1) {
|
||||||
reject();
|
callback();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
resolve({
|
callback({
|
||||||
authCredentials: {
|
authCredentials: {
|
||||||
username: logins[0].username,
|
username: logins[0].username,
|
||||||
password: logins[0].password
|
password: logins[0].password
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}, function () {
|
}, function () {
|
||||||
reject();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
bg_loginService.getAllDecryptedForDomain(domain).then(function (logins) {
|
|
||||||
if (!logins || logins.length !== 1) {
|
|
||||||
callback();
|
callback();
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
callback({
|
|
||||||
authCredentials: {
|
|
||||||
username: logins[0].username,
|
|
||||||
password: logins[0].password
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}, function () {
|
}
|
||||||
callback();
|
}, { urls: ['http://*/*', 'https://*/*'] }, [bg_utilsService.isFirefox() ? 'blocking' : 'asyncBlocking']);
|
||||||
});
|
|
||||||
}
|
|
||||||
}, { urls: ['http://*/*', 'https://*/*'] }, [bg_utilsService.isFirefox() ? 'blocking' : 'asyncBlocking']);
|
|
||||||
|
|
||||||
chrome.webRequest.onCompleted.addListener(completeAuthRequest, { urls: ['http://*/*'] });
|
chrome.webRequest.onCompleted.addListener(completeAuthRequest, { urls: ['http://*/*'] });
|
||||||
chrome.webRequest.onErrorOccurred.addListener(completeAuthRequest, { urls: ['http://*/*'] });
|
chrome.webRequest.onErrorOccurred.addListener(completeAuthRequest, { urls: ['http://*/*'] });
|
||||||
|
|
||||||
function completeAuthRequest(details) {
|
function completeAuthRequest(details) {
|
||||||
var i = pendingAuthRequests.indexOf(details.requestId);
|
var i = pendingAuthRequests.indexOf(details.requestId);
|
||||||
if (i > -1) {
|
if (i > -1) {
|
||||||
pendingAuthRequests.splice(i, 1);
|
pendingAuthRequests.splice(i, 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user