diff --git a/src/popup/vault/add-edit.component.ts b/src/popup/vault/add-edit.component.ts
index d6f5bd7339..b717e8cb0a 100644
--- a/src/popup/vault/add-edit.component.ts
+++ b/src/popup/vault/add-edit.component.ts
@@ -18,13 +18,17 @@ import { PlatformUtilsService } from 'jslib/abstractions/platformUtils.service';
import { PolicyService } from 'jslib/abstractions/policy.service';
import { StateService } from 'jslib/abstractions/state.service';
import { UserService } from 'jslib/abstractions/user.service';
+import { StorageService } from 'jslib/abstractions/storage.service';
import { PopupUtilsService } from '../services/popup-utils.service';
+import { ConstantsService } from 'jslib/services/constants.service';
import { LoginUriView } from 'jslib/models/view/loginUriView';
import { AddEditComponent as BaseAddEditComponent } from 'jslib/angular/components/add-edit.component';
+import { CipherType } from 'jslib/enums/cipherType';
+
@Component({
selector: 'app-vault-add-edit',
templateUrl: 'add-edit.component.html',
@@ -33,6 +37,7 @@ export class AddEditComponent extends BaseAddEditComponent {
currentUris: string[];
showAttachments = true;
openAttachmentsInPopup: boolean;
+ showAutoFillOnPageLoadOptions: boolean;
constructor(cipherService: CipherService, folderService: FolderService,
i18nService: I18nService, platformUtilsService: PlatformUtilsService,
@@ -41,7 +46,7 @@ export class AddEditComponent extends BaseAddEditComponent {
messagingService: MessagingService, private route: ActivatedRoute,
private router: Router, private location: Location,
eventService: EventService, policyService: PolicyService,
- private popupUtilsService: PopupUtilsService) {
+ private popupUtilsService: PopupUtilsService, private storageService: StorageService) {
super(cipherService, folderService, i18nService, platformUtilsService, auditService, stateService,
userService, collectionService, messagingService, eventService, policyService);
}
@@ -108,6 +113,12 @@ export class AddEditComponent extends BaseAddEditComponent {
}, 200);
}
+ async load() {
+ await super.load();
+ this.showAutoFillOnPageLoadOptions = this.cipher.type === CipherType.Login &&
+ await this.storageService.get(ConstantsService.enableAutoFillOnPageLoadKey);
+ }
+
async submit(): Promise {
if (await super.submit()) {
if (this.cloneMode) {
diff --git a/src/services/autofill.service.ts b/src/services/autofill.service.ts
index 386ad20e78..755705f898 100644
--- a/src/services/autofill.service.ts
+++ b/src/services/autofill.service.ts
@@ -246,12 +246,16 @@ export default class AutofillService implements AutofillServiceInterface {
if (fromCommand) {
cipher = await this.cipherService.getNextCipherForUrl(tab.url);
} else {
- const lastLaunchedCipher = await this.cipherService.getLastLaunchedForUrl(tab.url);
+ const lastLaunchedCipher = await this.cipherService.getLastLaunchedForUrl(tab.url, true);
if (lastLaunchedCipher && Date.now().valueOf() - lastLaunchedCipher.localData?.lastLaunched?.valueOf() < 30000) {
cipher = lastLaunchedCipher;
}
else {
- cipher = await this.cipherService.getLastUsedForUrl(tab.url);
+ cipher = await this.cipherService.getLastUsedForUrl(tab.url, true);
+ }
+
+ if (cipher == null) {
+ return null;
}
}