Skip to content

Commit

Permalink
Merge pull request keepassxreboot#1304 from keepassxreboot/fix/switch…
Browse files Browse the repository at this point in the history
…_from_index_to_uuid

Switch from index to uuid
  • Loading branch information
Sami Vänttinen authored Apr 12, 2021
2 parents 4cf1731 + 06d439d commit dc3e680
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 18 deletions.
2 changes: 1 addition & 1 deletion keepassxc-browser/content/credential-autocomplete.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ CredentialAutocomplete.prototype.fillPassword = async function(value, index, uui
const combination = await kpxcFields.getCombination(this.input);
combination.loginId = index;

await sendMessage('page_set_login_id', index);
await sendMessage('page_set_login_id', uuid);

const manualFill = await sendMessage('page_get_manual_fill');
await kpxc.fillInCredentials(combination, value, uuid, manualFill === ManualFill.PASSWORD);
Expand Down
32 changes: 18 additions & 14 deletions keepassxc-browser/content/keepassxc-browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -920,7 +920,7 @@ kpxc.fillInFromActiveElement = async function(passOnly = false) {
return;
}

await sendMessage('page_set_login_id', 0);
await sendMessage('page_set_login_id', '');
kpxc.fillInCredentials(combination, kpxc.credentials[0].login, kpxc.credentials[0].uuid, passOnly);
};

Expand All @@ -931,7 +931,7 @@ kpxc.fillFromAutofill = async function() {
}

const index = kpxc.combinations.length - 1;
await sendMessage('page_set_login_id', 0);
await sendMessage('page_set_login_id', '');
kpxc.fillInCredentials(kpxc.combinations[index], kpxc.credentials[0].login, kpxc.credentials[0].uuid);

// Generate popup-list of usernames + descriptions
Expand All @@ -944,7 +944,7 @@ kpxc.fillFromPopup = async function(id, uuid) {
return;
}

await sendMessage('page_set_login_id', id);
await sendMessage('page_set_login_id', uuid);
const selectedCredentials = kpxc.credentials.find(c => c.uuid === uuid);
if (!selectedCredentials) {
console.log('Error: Uuid not found: ', uuid);
Expand Down Expand Up @@ -1041,7 +1041,7 @@ kpxc.fillFromUsernameIcon = async function(combination) {
return;
}

await sendMessage('page_set_login_id', 0);
await sendMessage('page_set_login_id', '');
kpxc.fillInCredentials(combination, kpxc.credentials[0].login, kpxc.credentials[0].uuid);
};

Expand Down Expand Up @@ -1508,9 +1508,12 @@ kpxc.rememberCredentials = async function(usernameValue, passwordValue, urlValue
if (credentialsList.length === 1) {
usernameValue = credentialsList[0].login;
} else if (credentialsList.length > 1) {
const index = await sendMessage('page_get_login_id');
if (index >= 0) {
usernameValue = credentialsList[index].login;
const uuid = await sendMessage('page_get_login_id');
if (uuid) {
const credsFromUuid = credentialsList.find(c => c.uuid === uuid);
if (credsFromUuid) {
usernameValue = credsFromUuid.login;
}
}
}
}
Expand Down Expand Up @@ -1706,20 +1709,21 @@ kpxc.updateDatabaseState = async function() {

// Updates the TOTP Autocomplete Menu
kpxc.updateTOTPList = async function() {
let index = await sendMessage('page_get_login_id');
if (index < 0) {
let uuid = await sendMessage('page_get_login_id');
if (uuid === undefined) {
// Credential haven't been selected
return;
}

// Use the first credential available if not set
if (index === undefined) {
index = 0;
if (uuid === '') {
uuid = kpxc.credentials[0].uuid;
}

if (index >= 0 && kpxc.credentials[index]) {
const username = kpxc.credentials[index].login;
const password = kpxc.credentials[index].password;
const credentials = kpxc.credentials.find(c => c.uuid === uuid);
if (credentials) {
const username = credentials.login;
const password = credentials.password;

// If no username is set, compare with a password
const credentialList = kpxc.credentials.filter(c => (c.totp || (c.stringFields && c.stringFields.some(s => s['KPH: {TOTP}'])))
Expand Down
4 changes: 2 additions & 2 deletions keepassxc-browser/manifest.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"manifest_version": 2,
"name": "KeePassXC-Browser",
"version": "1.7.8",
"version_name": "1.7.8",
"version": "1.7.8.1",
"version_name": "1.7.8.1",
"description": "__MSG_extensionDescription__",
"author": "KeePassXC Team",
"icons": {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "KeePassXC-Browser",
"version": "1.7.8",
"version": "1.7.8.1",
"description": "KeePassXC-Browser",
"main": "build.js",
"devDependencies": {
Expand Down

0 comments on commit dc3e680

Please sign in to comment.