mirror of
https://github.com/bitwarden/browser
synced 2025-12-17 08:43:33 +00:00
Merge branch 'master' of https://github.com/bitwarden/browser into feature/safari-webext
# Conflicts: # src/background/runtime.background.ts
This commit is contained in:
@@ -11,8 +11,10 @@ import { ConstantsService } from 'jslib/services/constants.service';
|
||||
import { EnvironmentService } from 'jslib/abstractions/environment.service';
|
||||
import { I18nService } from 'jslib/abstractions/i18n.service';
|
||||
import { NotificationsService } from 'jslib/abstractions/notifications.service';
|
||||
import { PolicyService } from 'jslib/abstractions/policy.service';
|
||||
import { StorageService } from 'jslib/abstractions/storage.service';
|
||||
import { SystemService } from 'jslib/abstractions/system.service';
|
||||
import { UserService } from 'jslib/abstractions/user.service';
|
||||
import { VaultTimeoutService } from 'jslib/abstractions/vaultTimeout.service';
|
||||
|
||||
import { BrowserApi } from '../browser/browserApi';
|
||||
@@ -22,6 +24,9 @@ import MainBackground from './main.background';
|
||||
import { Analytics } from 'jslib/misc';
|
||||
import { Utils } from 'jslib/misc/utils';
|
||||
|
||||
import { OrganizationUserStatusType } from 'jslib/enums/organizationUserStatusType';
|
||||
import { PolicyType } from 'jslib/enums/policyType';
|
||||
|
||||
export default class RuntimeBackground {
|
||||
private runtime: any;
|
||||
private autofillTimeout: any;
|
||||
@@ -33,7 +38,8 @@ export default class RuntimeBackground {
|
||||
private storageService: StorageService, private i18nService: I18nService,
|
||||
private analytics: Analytics, private notificationsService: NotificationsService,
|
||||
private systemService: SystemService, private vaultTimeoutService: VaultTimeoutService,
|
||||
private environmentService: EnvironmentService) {
|
||||
private environmentService: EnvironmentService, private policyService: PolicyService,
|
||||
private userService: UserService) {
|
||||
this.runtime = chrome.runtime;
|
||||
|
||||
// onInstalled listener must be wired up before anything else, so we do it in the ctor
|
||||
@@ -309,6 +315,11 @@ export default class RuntimeBackground {
|
||||
if (disabledAddLogin) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!(await this.allowPersonalOwnership())) {
|
||||
return;
|
||||
}
|
||||
|
||||
// remove any old messages for this tab
|
||||
this.removeTabFromNotificationQueue(tab);
|
||||
this.main.notificationQueue.push({
|
||||
@@ -413,8 +424,9 @@ export default class RuntimeBackground {
|
||||
const responseData: any = {};
|
||||
if (responseCommand === 'notificationBarDataResponse') {
|
||||
responseData.neverDomains = await this.storageService.get<any>(ConstantsService.neverDomainsKey);
|
||||
responseData.disabledAddLoginNotification = await this.storageService.get<boolean>(
|
||||
const disableAddLoginFromOptions = await this.storageService.get<boolean>(
|
||||
ConstantsService.disableAddLoginNotificationKey);
|
||||
responseData.disabledAddLoginNotification = disableAddLoginFromOptions || !(await this.allowPersonalOwnership());
|
||||
responseData.disabledChangedPasswordNotification = await this.storageService.get<boolean>(
|
||||
ConstantsService.disableChangedPasswordNotificationKey);
|
||||
} else if (responseCommand === 'autofillerAutofillOnPageLoadEnabledResponse') {
|
||||
@@ -436,4 +448,20 @@ export default class RuntimeBackground {
|
||||
|
||||
await BrowserApi.tabSendMessageData(tab, responseCommand, responseData);
|
||||
}
|
||||
|
||||
private async allowPersonalOwnership(): Promise<boolean> {
|
||||
const personalOwnershipPolicies = await this.policyService.getAll(PolicyType.PersonalOwnership);
|
||||
if (personalOwnershipPolicies != null) {
|
||||
for (const policy of personalOwnershipPolicies) {
|
||||
if (policy.enabled) {
|
||||
const org = await this.userService.getOrganization(policy.organizationId);
|
||||
if (org != null && org.enabled && org.usePolicies && !org.isAdmin
|
||||
&& org.status == OrganizationUserStatusType.Confirmed) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user