diff --git a/src/popup/settings/options.component.ts b/src/popup/settings/options.component.ts
index e5cf6322bbb..80a145e318d 100644
--- a/src/popup/settings/options.component.ts
+++ b/src/popup/settings/options.component.ts
@@ -23,6 +23,7 @@ import { ConstantsService } from 'jslib/services/constants.service';
export class OptionsComponent implements OnInit {
disableFavicon = false;
enableAutoFillOnPageLoad = false;
+ enableAutoTotpCopyOnAutoFill = false;
disableAutoTotpCopy = false;
disableContextMenuItem = false;
disableAddLoginNotification = false;
@@ -70,6 +71,8 @@ export class OptionsComponent implements OnInit {
this.enableAutoFillOnPageLoad = await this.storageService.get(
ConstantsService.enableAutoFillOnPageLoadKey);
+ this.enableAutoTotpCopyOnAutoFill = await this.totpService.isAutoCopyOnAutoFillEnabled();
+
this.disableAddLoginNotification = await this.storageService.get(
ConstantsService.disableAddLoginNotificationKey);
@@ -120,9 +123,20 @@ export class OptionsComponent implements OnInit {
async updateAutoFillOnPageLoad() {
await this.storageService.save(ConstantsService.enableAutoFillOnPageLoadKey, this.enableAutoFillOnPageLoad);
+ if (!this.enableAutoFillOnPageLoad) {
+ // If we disable Auto Fill on Page Load, also disable Copying of TOTP
+ await this.storageService.save(ConstantsService.enableAutoTotpCopyOnAutoFill, false);
+ // TODO the below reloads the entire extension, I just want to reload the current view, or at least the enable auto totp copy checkbox
+ window.setTimeout(() => window.location.reload(), 200);
+ }
this.callAnalytics('Auto-fill Page Load', this.enableAutoFillOnPageLoad);
}
+ async updateAutoTotpCopyOnAutoFill() {
+ await this.storageService.save(ConstantsService.enableAutoTotpCopyOnAutoFill, this.enableAutoTotpCopyOnAutoFill);
+ this.callAnalytics('Auto Copy TOTP on Page Load', this.enableAutoTotpCopyOnAutoFill);
+ }
+
async updateDisableFavicon() {
await this.storageService.save(ConstantsService.disableFaviconKey, this.disableFavicon);
await this.stateService.save(ConstantsService.disableFaviconKey, this.disableFavicon);
diff --git a/src/services/autofill.service.ts b/src/services/autofill.service.ts
index 841e27098d4..9cb3822219d 100644
--- a/src/services/autofill.service.ts
+++ b/src/services/autofill.service.ts
@@ -254,10 +254,12 @@ export default class AutofillService implements AutofillServiceInterface {
}
}
+ const shouldCopyTotpOnAutoFill = await this.totpService.isAutoCopyOnAutoFillEnabled();
+
const totpCode = await this.doAutoFill({
cipher: cipher,
pageDetails: pageDetails,
- skipTotp: !fromCommand,
+ skipTotp: !fromCommand && !shouldCopyTotpOnAutoFill,
skipLastUsed: !fromCommand,
skipUsernameOnlyFill: !fromCommand,
onlyEmptyFields: !fromCommand,