Skip to content

Commit

Permalink
Force asking where to save if entry already exists for new domain
Browse files Browse the repository at this point in the history
  • Loading branch information
luckyrat committed Jul 1, 2020
1 parent f89f2e1 commit 82d983c
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion popup/components/Save1stParty.vue
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ import { configManager } from "../../common/ConfigManager";
import { DatabaseSummary } from "../../common/model/DatabaseSummary";
import { Database } from "../../common/model/Database";
import { Group } from "../../common/model/Group";
import { SearcherAll } from "../../common/SearcherAll";
export default {
components: {
Expand Down Expand Up @@ -189,7 +190,7 @@ export default {
this.preferredDb = preferredDb;
this.primaryFound = primaryFound;
this.domainMatchesExistingEntry = false; //TODO:* search all entries for matching domain using this.entryDomain computed property (if available at this point in the lifecycle)
this.domainMatchesExistingEntry = this.anyEntryMatchesNewDomain();
if (this.preferredGroupUuid && this.preferredDb && !this.domainMatchesExistingEntry) {
this.skipWhere = true;
Expand Down Expand Up @@ -302,6 +303,27 @@ export default {
preferredDb: null,
primaryFound
};
},
anyEntryMatchesNewDomain: function (this: any) {
const urlStr = (this.saveState as SaveState).newEntry.URLs[0];
if (!urlStr || urlStr.length < 4) return false;
const kurl = KeeURL.fromString(urlStr);
if (!kurl) {
return false;
}
const search = new SearcherAll(
{
KeePassDatabases: this.$store.getters.KeePassDatabases,
ActiveKeePassDatabaseIndex: this.$store.getters.ActiveKeePassDatabaseIndex
} as any,
{
version: 1,
searchAllDatabases: configManager.current.searchAllOpenDBs,
maximumResults: 1
}
);
const results = search.execute("", undefined, [kurl.domainOrIPAddress]);
return !!results?.length;
}
}
};
Expand Down

0 comments on commit 82d983c

Please sign in to comment.