1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-12 14:23:32 +00:00

Merge pull request #1626 from tomershvueli/copy-totp-on-auto-fill

feat: Add option to auto-copy TOTP code when page auto fills credentials
This commit is contained in:
Thomas Rittson
2021-05-05 12:29:57 +10:00
committed by GitHub
5 changed files with 31 additions and 3 deletions

2
jslib

Submodule jslib updated: a72c8a60c1...2841cff90a

View File

@@ -898,6 +898,12 @@
"enableAutoFillOnPageLoadDesc": {
"message": "If a login form is detected, automatically perform an auto-fill when the web page loads."
},
"enableAutoTotpCopyOnAutoFill": {
"message": "Automatic TOTP Copy after Page Load"
},
"enableAutoTotpCopyOnAutoFillDesc": {
"message": "If Auto-fill On Page Load is enabled, and your login has an authenticator key attached to it, the TOTP verification code is automatically copied to your clipboard after loading the web page."
},
"experimentalFeature": {
"message": "This is currently an experimental feature. Use at your own risk."
},

View File

@@ -24,6 +24,18 @@
<b>{{'warning' | i18n}}</b>: {{'experimentalFeature' | i18n}}
</div>
</div>
<div class="box">
<div class="box-content">
<div class="box-content-row box-content-row-checkbox" appBoxRow>
<label for="autoCopyTotp">{{'enableAutoTotpCopyOnAutoFill' | i18n}}</label>
<input id="autoCopyTotp" type="checkbox" (change)="updateAutoTotpCopyOnAutoFill()"
[(ngModel)]="enableAutoTotpCopyOnAutoFill" [disabled]="!enableAutoFillOnPageLoad">
</div>
</div>
<div class="box-footer">
{{'enableAutoTotpCopyOnAutoFillDesc' | i18n}}
</div>
</div>
<div class="box">
<div class="box-content">
<div class="box-content-row" appBoxRow>

View File

@@ -22,6 +22,7 @@ export class OptionsComponent implements OnInit {
disableFavicon = false;
disableBadgeCounter = false;
enableAutoFillOnPageLoad = false;
enableAutoTotpCopyOnAutoFill = false;
disableAutoTotpCopy = false;
disableContextMenuItem = false;
disableAddLoginNotification = false;
@@ -68,6 +69,8 @@ export class OptionsComponent implements OnInit {
this.enableAutoFillOnPageLoad = await this.storageService.get<boolean>(
ConstantsService.enableAutoFillOnPageLoadKey);
this.enableAutoTotpCopyOnAutoFill = await this.totpService.isAutoCopyOnAutoFillEnabled();
this.disableAddLoginNotification = await this.storageService.get<boolean>(
ConstantsService.disableAddLoginNotificationKey);
@@ -118,6 +121,10 @@ export class OptionsComponent implements OnInit {
await this.storageService.save(ConstantsService.enableAutoFillOnPageLoadKey, this.enableAutoFillOnPageLoad);
}
async updateAutoTotpCopyOnAutoFill() {
await this.storageService.save(ConstantsService.enableAutoTotpCopyOnAutoFillKey, this.enableAutoTotpCopyOnAutoFill);
}
async updateDisableFavicon() {
await this.storageService.save(ConstantsService.disableFaviconKey, this.disableFavicon);
await this.stateService.save(ConstantsService.disableFaviconKey, this.disableFavicon);

View File

@@ -258,11 +258,14 @@ export default class AutofillService implements AutofillServiceInterface {
if (cipher.reprompt !== CipherRepromptType.None) {
return;
}
const copyTotpOnAutoFill = await this.totpService.isAutoCopyOnAutoFillEnabled();
const shouldCopyTotp = fromCommand || copyTotpOnAutoFill;
const totpCode = await this.doAutoFill({
cipher: cipher,
pageDetails: pageDetails,
skipTotp: !fromCommand,
skipTotp: !shouldCopyTotp,
skipLastUsed: !fromCommand,
skipUsernameOnlyFill: !fromCommand,
onlyEmptyFields: !fromCommand,