mirror of
https://github.com/keepassxreboot/keepassxc-browser.git
synced 2026-03-11 08:54:43 +00:00
Automatically fill credentials when site preference override for the setting is present
This commit is contained in:
parent
9a07a9d7c5
commit
07ae4bd06a
1 changed files with 33 additions and 1 deletions
|
|
@ -501,15 +501,47 @@ kpxc.prepareCredentials = async function() {
|
|||
return;
|
||||
}
|
||||
|
||||
if (kpxc.settings.autoFillSingleEntry && kpxc.credentials.length === 1) {
|
||||
if (kpxc.credentials.length === 1) {
|
||||
if (kpxc.settings.autoFillSingleEntry) {
|
||||
kpxcFill.fillFromAutofill();
|
||||
return;
|
||||
}
|
||||
|
||||
// Check for site preference overrides
|
||||
const sitePreference = kpxc.retrieveSitePreference();
|
||||
if (sitePreference !== null && sitePreference !== undefined) {
|
||||
if (sitePreference.autoFillCredentials === true) {
|
||||
kpxcFill.fillFromAutofill();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
kpxc.initLoginPopup();
|
||||
kpxc.initAutocomplete();
|
||||
};
|
||||
|
||||
kpxc.retrieveSitePreference = function() {
|
||||
// Check for autofill site preferences
|
||||
for (const site of kpxc.settings.sitePreferences) {
|
||||
let currentLocation;
|
||||
try {
|
||||
currentLocation = window.top.location.href;
|
||||
} catch (err) {
|
||||
// Cross-domain security error inspecting window.top.location.href.
|
||||
// This catches an error when an iframe is being accessed from another (sub)domain
|
||||
// -> use the iframe URL instead.
|
||||
currentLocation = window.self.location.href;
|
||||
}
|
||||
|
||||
if (siteMatch(site.url, currentLocation) || site.url === currentLocation) {
|
||||
return site;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the credential list and shows the update banner
|
||||
* @param {string} usernameValue Submitted username
|
||||
|
|
|
|||
Loading…
Reference in a new issue