mirror of
https://github.com/bitwarden/browser
synced 2025-12-16 16:23:44 +00:00
feat: Add option to auto-copy TOTP code when page auto fills credentials
This commit is contained in:
@@ -885,6 +885,12 @@
|
|||||||
"enableAutoFillOnPageLoadDesc": {
|
"enableAutoFillOnPageLoadDesc": {
|
||||||
"message": "If a login form is detected, automatically perform an auto-fill when the web page loads."
|
"message": "If a login form is detected, automatically perform an auto-fill when the web page loads."
|
||||||
},
|
},
|
||||||
|
"enableAutoTotpCopyOnAutoFill": {
|
||||||
|
"message": "Enable Copy to Clipboard of TOTP On Page Auto-fill"
|
||||||
|
},
|
||||||
|
"enableAutoTotpCopyOnAutoFillDesc": {
|
||||||
|
"message": "If login auto-fills on page load and TOTP exists for this login, copy to clipboard without prompt"
|
||||||
|
},
|
||||||
"experimentalFeature": {
|
"experimentalFeature": {
|
||||||
"message": "This is currently an experimental feature. Use at your own risk."
|
"message": "This is currently an experimental feature. Use at your own risk."
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -24,6 +24,19 @@
|
|||||||
<b>{{'warning' | i18n}}</b>: {{'experimentalFeature' | i18n}}
|
<b>{{'warning' | i18n}}</b>: {{'experimentalFeature' | i18n}}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="box">
|
||||||
|
<div class="box-content">
|
||||||
|
<div class="box-content-row box-content-row-checkbox" appBoxRow>
|
||||||
|
<label for="autofill">{{'enableAutoTotpCopyOnAutoFill' | i18n}}</label>
|
||||||
|
<input id="autofill" type="checkbox" (change)="updateAutoTotpCopyOnAutoFill()"
|
||||||
|
[(ngModel)]="enableAutoTotpCopyOnAutoFill" [disabled]="!enableAutoFillOnPageLoad">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="box-footer">
|
||||||
|
{{'enableAutoTotpCopyOnAutoFillDesc' | i18n}}
|
||||||
|
<b>{{'warning' | i18n}}</b>: {{'experimentalFeature' | i18n}}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<div class="box">
|
<div class="box">
|
||||||
<div class="box-content">
|
<div class="box-content">
|
||||||
<div class="box-content-row" appBoxRow>
|
<div class="box-content-row" appBoxRow>
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ import { ConstantsService } from 'jslib/services/constants.service';
|
|||||||
export class OptionsComponent implements OnInit {
|
export class OptionsComponent implements OnInit {
|
||||||
disableFavicon = false;
|
disableFavicon = false;
|
||||||
enableAutoFillOnPageLoad = false;
|
enableAutoFillOnPageLoad = false;
|
||||||
|
enableAutoTotpCopyOnAutoFill = false;
|
||||||
disableAutoTotpCopy = false;
|
disableAutoTotpCopy = false;
|
||||||
disableContextMenuItem = false;
|
disableContextMenuItem = false;
|
||||||
disableAddLoginNotification = false;
|
disableAddLoginNotification = false;
|
||||||
@@ -70,6 +71,8 @@ export class OptionsComponent implements OnInit {
|
|||||||
this.enableAutoFillOnPageLoad = await this.storageService.get<boolean>(
|
this.enableAutoFillOnPageLoad = await this.storageService.get<boolean>(
|
||||||
ConstantsService.enableAutoFillOnPageLoadKey);
|
ConstantsService.enableAutoFillOnPageLoadKey);
|
||||||
|
|
||||||
|
this.enableAutoTotpCopyOnAutoFill = await this.totpService.isAutoCopyOnAutoFillEnabled();
|
||||||
|
|
||||||
this.disableAddLoginNotification = await this.storageService.get<boolean>(
|
this.disableAddLoginNotification = await this.storageService.get<boolean>(
|
||||||
ConstantsService.disableAddLoginNotificationKey);
|
ConstantsService.disableAddLoginNotificationKey);
|
||||||
|
|
||||||
@@ -120,9 +123,20 @@ export class OptionsComponent implements OnInit {
|
|||||||
|
|
||||||
async updateAutoFillOnPageLoad() {
|
async updateAutoFillOnPageLoad() {
|
||||||
await this.storageService.save(ConstantsService.enableAutoFillOnPageLoadKey, this.enableAutoFillOnPageLoad);
|
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);
|
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() {
|
async updateDisableFavicon() {
|
||||||
await this.storageService.save(ConstantsService.disableFaviconKey, this.disableFavicon);
|
await this.storageService.save(ConstantsService.disableFaviconKey, this.disableFavicon);
|
||||||
await this.stateService.save(ConstantsService.disableFaviconKey, this.disableFavicon);
|
await this.stateService.save(ConstantsService.disableFaviconKey, this.disableFavicon);
|
||||||
|
|||||||
@@ -254,10 +254,12 @@ export default class AutofillService implements AutofillServiceInterface {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const shouldCopyTotpOnAutoFill = await this.totpService.isAutoCopyOnAutoFillEnabled();
|
||||||
|
|
||||||
const totpCode = await this.doAutoFill({
|
const totpCode = await this.doAutoFill({
|
||||||
cipher: cipher,
|
cipher: cipher,
|
||||||
pageDetails: pageDetails,
|
pageDetails: pageDetails,
|
||||||
skipTotp: !fromCommand,
|
skipTotp: !fromCommand && !shouldCopyTotpOnAutoFill,
|
||||||
skipLastUsed: !fromCommand,
|
skipLastUsed: !fromCommand,
|
||||||
skipUsernameOnlyFill: !fromCommand,
|
skipUsernameOnlyFill: !fromCommand,
|
||||||
onlyEmptyFields: !fromCommand,
|
onlyEmptyFields: !fromCommand,
|
||||||
|
|||||||
Reference in New Issue
Block a user