returning one matching entry automatically

This commit is contained in:
antelle 2021-04-28 17:59:47 +02:00
parent 732c35625b
commit 18524ad9eb
No known key found for this signature in database
GPG Key ID: 63C9777AAB7C563C
1 changed files with 17 additions and 14 deletions

View File

@ -415,29 +415,32 @@ const ProtocolHandlers = {
const client = getClient(request); const client = getClient(request);
const filter = new SelectEntryFilter({ url: payload.url }, appModel, files); const filter = new SelectEntryFilter({ url: payload.url }, appModel, files);
filter.subdomains = false;
const entries = filter.getEntries(); const entries = filter.getEntries();
if (!entries.length) { if (!entries.length) {
throw makeError(Errors.noMatches); throw makeError(Errors.noMatches);
} }
const topMessage = Locale.extensionSelectPasswordFor.replace( let entry;
'{}',
getHumanReadableExtensionName(client)
);
const selectEntryView = new SelectEntryView({
filter,
topMessage
});
focusKeeWeb(); if (entries.length === 1 && client.permissions.askGet === 'multiple') {
entry = entries[0];
} else {
filter.subdomains = true;
const extName = getHumanReadableExtensionName(client);
const topMessage = Locale.extensionSelectPasswordFor.replace('{}', extName);
const selectEntryView = new SelectEntryView({ filter, topMessage });
const result = await selectEntryView.showAndGetResult(); focusKeeWeb();
if (!result?.entry) {
throw makeError(Errors.userRejected); const result = await selectEntryView.showAndGetResult();
entry = result?.entry;
if (!entry) {
throw makeError(Errors.userRejected);
}
} }
const entry = result.entry;
client.stats.passwordsRead++; client.stats.passwordsRead++;
return encryptResponse(request, { return encryptResponse(request, {