mirror of
https://github.com/bitwarden/browser
synced 2025-12-15 07:43:35 +00:00
[AC-1046] activate autofill on page load policy (#4860)
* [EC-1046] add activate autofill policy to web * [EC-1046] add local setting if policy needs to be set * [AC-1046] activate autofill on page load if flag exists * [AC-1046] move activation to current tab page * [AC-1046] add warning to autofill policy * [AC-1046] add useActivateAutofillPolicy to organization reponse * [AC-1046] autofill to auto-fill
This commit is contained in:
@@ -2120,6 +2120,9 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"autofillPageLoadPolicyActivated": {
|
||||
"message": "Your organization policies have turned on auto-fill on page load."
|
||||
},
|
||||
"howToAutofill": {
|
||||
"message": "How to auto-fill"
|
||||
},
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
import { BehaviorSubject } from "rxjs";
|
||||
import { BehaviorSubject, filter, map, Observable, switchMap, tap } from "rxjs";
|
||||
import { Jsonify } from "type-fest";
|
||||
|
||||
import { OrganizationService } from "@bitwarden/common/abstractions/organization/organization.service.abstraction";
|
||||
import { StateService } from "@bitwarden/common/abstractions/state.service";
|
||||
import { PolicyType } from "@bitwarden/common/enums/policyType";
|
||||
import { Policy } from "@bitwarden/common/models/domain/policy";
|
||||
import { PolicyService } from "@bitwarden/common/services/policy/policy.service";
|
||||
|
||||
@@ -13,4 +16,29 @@ export class BrowserPolicyService extends PolicyService {
|
||||
initializeAs: "array",
|
||||
})
|
||||
protected _policies: BehaviorSubject<Policy[]>;
|
||||
|
||||
constructor(stateService: StateService, organizationService: OrganizationService) {
|
||||
super(stateService, organizationService);
|
||||
this._policies.pipe(this.handleActivateAutofillPolicy.bind(this)).subscribe();
|
||||
}
|
||||
|
||||
/**
|
||||
* If the ActivateAutofill policy is enabled, save a flag indicating if we need to
|
||||
* enable Autofill on page load.
|
||||
*/
|
||||
private handleActivateAutofillPolicy(policies$: Observable<Policy[]>) {
|
||||
return policies$.pipe(
|
||||
map((policies) => policies.find((p) => p.type == PolicyType.ActivateAutofill && p.enabled)),
|
||||
filter((p) => p != null),
|
||||
switchMap(async (_) => [
|
||||
await this.stateService.getActivateAutoFillOnPageLoadFromPolicy(),
|
||||
await this.stateService.getEnableAutoFillOnPageLoad(),
|
||||
]),
|
||||
tap(([activated, autofillEnabled]) => {
|
||||
if (activated === undefined) {
|
||||
this.stateService.setActivateAutoFillOnPageLoadFromPolicy(!autofillEnabled);
|
||||
}
|
||||
})
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -116,6 +116,17 @@ export class CurrentTabComponent implements OnInit, OnDestroy {
|
||||
this.search$
|
||||
.pipe(debounceTime(500), takeUntil(this.destroy$))
|
||||
.subscribe(() => this.searchVault());
|
||||
|
||||
// activate autofill on page load if policy is set
|
||||
if (await this.stateService.getActivateAutoFillOnPageLoadFromPolicy()) {
|
||||
await this.stateService.setEnableAutoFillOnPageLoad(true);
|
||||
await this.stateService.setActivateAutoFillOnPageLoadFromPolicy(false);
|
||||
this.platformUtilsService.showToast(
|
||||
"info",
|
||||
null,
|
||||
this.i18nService.t("autofillPageLoadPolicyActivated")
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
ngOnDestroy() {
|
||||
|
||||
@@ -6,6 +6,7 @@ import { first } from "rxjs/operators";
|
||||
|
||||
import { VaultFilter } from "@bitwarden/angular/vault/vault-filter/models/vault-filter.model";
|
||||
import { BroadcasterService } from "@bitwarden/common/abstractions/broadcaster.service";
|
||||
import { I18nService } from "@bitwarden/common/abstractions/i18n.service";
|
||||
import { PlatformUtilsService } from "@bitwarden/common/abstractions/platformUtils.service";
|
||||
import { SearchService } from "@bitwarden/common/abstractions/search.service";
|
||||
import { TreeNode } from "@bitwarden/common/models/domain/tree-node";
|
||||
@@ -72,6 +73,7 @@ export class VaultFilterComponent implements OnInit, OnDestroy {
|
||||
private allCiphers: CipherView[] = null;
|
||||
|
||||
constructor(
|
||||
private i18nService: I18nService,
|
||||
private cipherService: CipherService,
|
||||
private router: Router,
|
||||
private ngZone: NgZone,
|
||||
|
||||
@@ -4853,6 +4853,18 @@
|
||||
"personalVaultExportPolicyInEffect": {
|
||||
"message": "One or more organization policies prevents you from exporting your individual vault."
|
||||
},
|
||||
"activateAutofill": {
|
||||
"message": "Activate auto-fill"
|
||||
},
|
||||
"activateAutofillDesc": {
|
||||
"message": "Activate the auto-fill with page load settings on the browser extension for all existing and new members."
|
||||
},
|
||||
"experimentalFeature": {
|
||||
"message": "Compromised or untrusted websites can exploit auto-fill on page load."
|
||||
},
|
||||
"learnMoreAboutAutofill": {
|
||||
"message": "Learn more about auto-fill"
|
||||
},
|
||||
"selectType": {
|
||||
"message": "Select SSO type"
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user