From fdfb6fb152b8aef85832012396c71485da9bc399 Mon Sep 17 00:00:00 2001 From: Addison Beck Date: Mon, 12 Oct 2020 13:33:26 -0400 Subject: [PATCH 1/2] tracked last-launched ciphers for autofill --- jslib | 2 +- src/popup/vault/ciphers.component.ts | 5 ++++- src/popup/vault/groupings.component.ts | 1 + src/services/autofill.service.ts | 7 +++++++ 4 files changed, 13 insertions(+), 2 deletions(-) diff --git a/jslib b/jslib index e371d737b0..9e9795fd85 160000 --- a/jslib +++ b/jslib @@ -1 +1 @@ -Subproject commit e371d737b0d3db99f195c3317ecf9eaa16bd19b3 +Subproject commit 9e9795fd855d643459a9205c5299bfbf887d4985 diff --git a/src/popup/vault/ciphers.component.ts b/src/popup/vault/ciphers.component.ts index e804449f27..a241102a4b 100644 --- a/src/popup/vault/ciphers.component.ts +++ b/src/popup/vault/ciphers.component.ts @@ -15,6 +15,7 @@ import { import { BrowserApi } from '../../browser/browserApi'; +import { CipherService } from 'jslib/abstractions/cipher.service'; import { CollectionService } from 'jslib/abstractions/collection.service'; import { FolderService } from 'jslib/abstractions/folder.service'; import { I18nService } from 'jslib/abstractions/i18n.service'; @@ -62,7 +63,8 @@ export class CiphersComponent extends BaseCiphersComponent implements OnInit, On private changeDetectorRef: ChangeDetectorRef, private stateService: StateService, private popupUtils: PopupUtilsService, private i18nService: I18nService, private folderService: FolderService, private collectionService: CollectionService, - private analytics: Angulartics2, private platformUtilsService: PlatformUtilsService) { + private analytics: Angulartics2, private platformUtilsService: PlatformUtilsService, + private cipherService: CipherService) { super(searchService); this.pageSize = 100; this.applySavedState = (window as any).previousPopupUrl != null && @@ -195,6 +197,7 @@ export class CiphersComponent extends BaseCiphersComponent implements OnInit, On } this.preventSelected = true; this.analytics.eventTrack.next({ action: 'Launched URI From Listing' }); + await this.cipherService.updateLastLaunchedDate(cipher.id); BrowserApi.createNewTab(cipher.login.launchUri); if (this.popupUtils.inPopup(window)) { BrowserApi.closePopup(window); diff --git a/src/popup/vault/groupings.component.ts b/src/popup/vault/groupings.component.ts index d32f9a3152..84aca18084 100644 --- a/src/popup/vault/groupings.component.ts +++ b/src/popup/vault/groupings.component.ts @@ -286,6 +286,7 @@ export class GroupingsComponent extends BaseGroupingsComponent implements OnInit } this.preventSelected = true; this.analytics.eventTrack.next({ action: 'Launched URI From Listing' }); + await this.cipherService.updateLastLaunchedDate(cipher.id); BrowserApi.createNewTab(cipher.login.launchUri); if (this.popupUtils.inPopup(window)) { BrowserApi.closePopup(window); diff --git a/src/services/autofill.service.ts b/src/services/autofill.service.ts index 250d8619fb..d36d4b5c66 100644 --- a/src/services/autofill.service.ts +++ b/src/services/autofill.service.ts @@ -232,6 +232,13 @@ export default class AutofillService implements AutofillServiceInterface { cipher = await this.cipherService.getNextCipherForUrl(tab.url); } else { cipher = await this.cipherService.getLastUsedForUrl(tab.url); + const lastLaunchedCipher = await this.cipherService.getLastLaunchedForUrl(tab.url); + if (lastLaunchedCipher && Date.now().valueOf() - lastLaunchedCipher.localData?.lastLaunched?.valueOf() < 30000) { + cipher = lastLaunchedCipher; + } + else { + cipher = await this.cipherService.getLastUsedForUrl(tab.url); + } } const autoFillResponse = await this.doAutoFill({ From 3d903bbf0cd6e2694f907b105fef73f015e2313c Mon Sep 17 00:00:00 2001 From: Addison Beck Date: Tue, 13 Oct 2020 15:33:28 -0400 Subject: [PATCH 2/2] removed an uneeded line of code --- src/services/autofill.service.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/services/autofill.service.ts b/src/services/autofill.service.ts index d36d4b5c66..74912f26dc 100644 --- a/src/services/autofill.service.ts +++ b/src/services/autofill.service.ts @@ -231,7 +231,6 @@ export default class AutofillService implements AutofillServiceInterface { if (fromCommand) { cipher = await this.cipherService.getNextCipherForUrl(tab.url); } else { - cipher = await this.cipherService.getLastUsedForUrl(tab.url); const lastLaunchedCipher = await this.cipherService.getLastLaunchedForUrl(tab.url); if (lastLaunchedCipher && Date.now().valueOf() - lastLaunchedCipher.localData?.lastLaunched?.valueOf() < 30000) { cipher = lastLaunchedCipher;