1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-12-22 16:29:09 +01:00

Merge pull request #1455 from eliykat/feature-aopl-options

"Auto-fill on page load" options
This commit is contained in:
Thomas Rittson 2021-05-18 10:15:24 +10:00 committed by GitHub
commit b827614563
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 72 additions and 4 deletions

2
jslib

@ -1 +1 @@
Subproject commit 8659d0975ddb7dc70c0246b4b9acf81e013cdde3
Subproject commit 3d4ecaeb6aa5a09c74ce23ee526499f408aee02d

View File

@ -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"
},

View File

@ -161,5 +161,17 @@
<b>{{'warning' | i18n}}</b>: {{'experimentalFeature' | i18n}}
</div>
</div>
<div class="box">
<div class="box-content">
<div class="box-content-row" appBoxRow>
<label for="defaultAutofill">{{'defaultAutoFillOnPageLoad' | i18n}}</label>
<select id="defaultAutofill" name="DefaultAutofill" [(ngModel)]="autoFillOnPageLoadDefault"
(change)="updateAutoFillOnPageLoadDefault()" [disabled]="!enableAutoFillOnPageLoad">
<option *ngFor="let o of autoFillOnPageLoadOptions" [ngValue]="o.value">{{o.name}}</option>
</select>
</div>
</div>
<div class="box-footer">{{'defaultAutoFillOnPageLoadDesc' | i18n}}</div>
</div>
</ng-container>
</content>

View File

@ -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<boolean>(
ConstantsService.enableAutoFillOnPageLoadKey);
this.autoFillOnPageLoadDefault = await this.storageService.get<boolean>(
ConstantsService.autoFillOnPageLoadDefaultKey) ?? false;
this.disableAddLoginNotification = await this.storageService.get<boolean>(
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);

View File

@ -268,6 +268,16 @@
</a>
</div>
</div>
<div class="box" *ngIf="showAutoFillOnPageLoadOptions">
<div class="box-content">
<div class="box-content-row" appBoxRow>
<label for="autofillOnPageLoad">{{'itemAutoFillOnPageLoad' | i18n}} </label>
<select id="autofillOnPageLoad" name="AutofillOnPageLoad" [(ngModel)]="cipher.login.autofillOnPageLoad">
<option *ngFor="let o of autofillOnPageLoadOptions" [ngValue]="o.value">{{o.name}}</option>
</select>
</div>
</div>
</div>
<div class="box">
<div class="box-content">
<div class="box-content-row" appBoxRow>

View File

@ -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<boolean>(ConstantsService.enableAutoFillOnPageLoadKey);
}
async submit(): Promise<boolean> {
if (await super.submit()) {
if (this.cloneMode) {

View File

@ -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;
}
}