diff --git a/jslib b/jslib index 8659d0975d..3d4ecaeb6a 160000 --- a/jslib +++ b/jslib @@ -1 +1 @@ -Subproject commit 8659d0975ddb7dc70c0246b4b9acf81e013cdde3 +Subproject commit 3d4ecaeb6aa5a09c74ce23ee526499f408aee02d diff --git a/src/_locales/en/messages.json b/src/_locales/en/messages.json index 44d98f4cc8..2e22eaacd2 100644 --- a/src/_locales/en/messages.json +++ b/src/_locales/en/messages.json @@ -901,6 +901,24 @@ "experimentalFeature": { "message": "This is currently an experimental feature. Use at your own risk." }, + "defaultAutoFillOnPageLoad": { + "message": "Default autofill setting for login items" + }, + "defaultAutoFillOnPageLoadDesc": { + "message": "After enabling Auto-fill On Page Load, you can enable or disable the feature for individual login items. This is the default setting for login items that are not separately configured." + }, + "itemAutoFillOnPageLoad": { + "message": "Auto-fill On Page Load (if enabled in Options)" + }, + "autoFillOnPageLoadUseDefault": { + "message": "Use default setting" + }, + "autoFillOnPageLoadYes": { + "message": "Auto-fill on page load" + }, + "autoFillOnPageLoadNo": { + "message": "Do not auto-fill on page load" + }, "commandOpenPopup": { "message": "Open vault popup" }, diff --git a/src/popup/settings/options.component.html b/src/popup/settings/options.component.html index 83bbc329a6..77161c2c90 100644 --- a/src/popup/settings/options.component.html +++ b/src/popup/settings/options.component.html @@ -161,5 +161,17 @@ {{'warning' | i18n}}: {{'experimentalFeature' | i18n}} +
+
+
+ + +
+
+ +
diff --git a/src/popup/settings/options.component.ts b/src/popup/settings/options.component.ts index 60db20ae73..9ae845e356 100644 --- a/src/popup/settings/options.component.ts +++ b/src/popup/settings/options.component.ts @@ -21,6 +21,8 @@ export class OptionsComponent implements OnInit { disableFavicon = false; disableBadgeCounter = false; enableAutoFillOnPageLoad = false; + autoFillOnPageLoadDefault = false; + autoFillOnPageLoadOptions: any[]; disableAutoTotpCopy = false; disableContextMenuItem = false; disableAddLoginNotification = false; @@ -64,11 +66,18 @@ export class OptionsComponent implements OnInit { { name: i18nService.t('twoMinutes'), value: 120 }, { name: i18nService.t('fiveMinutes'), value: 300 }, ]; + this.autoFillOnPageLoadOptions = [ + { name: i18nService.t('autoFillOnPageLoadYes'), value: true }, + { name: i18nService.t('autoFillOnPageLoadNo'), value: false }, + ] } async ngOnInit() { this.enableAutoFillOnPageLoad = await this.storageService.get( ConstantsService.enableAutoFillOnPageLoadKey); + + this.autoFillOnPageLoadDefault = await this.storageService.get( + ConstantsService.autoFillOnPageLoadDefaultKey) ?? false; this.disableAddLoginNotification = await this.storageService.get( ConstantsService.disableAddLoginNotificationKey); @@ -120,6 +129,10 @@ export class OptionsComponent implements OnInit { await this.storageService.save(ConstantsService.enableAutoFillOnPageLoadKey, this.enableAutoFillOnPageLoad); } + async updateAutoFillOnPageLoadDefault() { + await this.storageService.save(ConstantsService.autoFillOnPageLoadDefaultKey, this.autoFillOnPageLoadDefault); + } + async updateDisableFavicon() { await this.storageService.save(ConstantsService.disableFaviconKey, this.disableFavicon); await this.stateService.save(ConstantsService.disableFaviconKey, this.disableFavicon); diff --git a/src/popup/vault/add-edit.component.html b/src/popup/vault/add-edit.component.html index 271f17e894..d7b3efaab7 100644 --- a/src/popup/vault/add-edit.component.html +++ b/src/popup/vault/add-edit.component.html @@ -268,6 +268,16 @@ +
+
+
+ + +
+
+
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; } }