mirror of
https://github.com/bitwarden/browser
synced 2025-12-17 16:53:34 +00:00
Exclude owners and admins from single organization policy when creating new org (#855)
* Fix single org policy when creating organization Exclude owners and admins from policy when creating new org * Remove looping async calls and fix linting
This commit is contained in:
@@ -19,10 +19,13 @@ import { I18nService } from 'jslib/abstractions/i18n.service';
|
|||||||
import { PlatformUtilsService } from 'jslib/abstractions/platformUtils.service';
|
import { PlatformUtilsService } from 'jslib/abstractions/platformUtils.service';
|
||||||
import { PolicyService } from 'jslib/abstractions/policy.service';
|
import { PolicyService } from 'jslib/abstractions/policy.service';
|
||||||
import { SyncService } from 'jslib/abstractions/sync.service';
|
import { SyncService } from 'jslib/abstractions/sync.service';
|
||||||
|
import { UserService } from 'jslib/abstractions/user.service';
|
||||||
|
|
||||||
import { PaymentComponent } from './payment.component';
|
import { PaymentComponent } from './payment.component';
|
||||||
import { TaxInfoComponent } from './tax-info.component';
|
import { TaxInfoComponent } from './tax-info.component';
|
||||||
|
|
||||||
|
import { OrganizationUserStatusType } from 'jslib/enums/organizationUserStatusType';
|
||||||
|
import { OrganizationUserType } from 'jslib/enums/organizationUserType';
|
||||||
import { PlanType } from 'jslib/enums/planType';
|
import { PlanType } from 'jslib/enums/planType';
|
||||||
import { PolicyType } from 'jslib/enums/policyType';
|
import { PolicyType } from 'jslib/enums/policyType';
|
||||||
import { ProductType } from 'jslib/enums/productType';
|
import { ProductType } from 'jslib/enums/productType';
|
||||||
@@ -66,7 +69,7 @@ export class OrganizationPlansComponent implements OnInit {
|
|||||||
private analytics: Angulartics2, private toasterService: ToasterService,
|
private analytics: Angulartics2, private toasterService: ToasterService,
|
||||||
platformUtilsService: PlatformUtilsService, private cryptoService: CryptoService,
|
platformUtilsService: PlatformUtilsService, private cryptoService: CryptoService,
|
||||||
private router: Router, private syncService: SyncService,
|
private router: Router, private syncService: SyncService,
|
||||||
private policyService: PolicyService) {
|
private policyService: PolicyService, private userService: UserService) {
|
||||||
this.selfHosted = platformUtilsService.isSelfHost();
|
this.selfHosted = platformUtilsService.isSelfHost();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -215,7 +218,18 @@ export class OrganizationPlansComponent implements OnInit {
|
|||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
const policies = await this.policyService.getAll(PolicyType.SingleOrg);
|
const policies = await this.policyService.getAll(PolicyType.SingleOrg);
|
||||||
this.singleOrgPolicyBlock = policies.some(policy => policy.enabled);
|
const orgs = await this.userService.getAllOrganizations();
|
||||||
|
|
||||||
|
const orgsWithSingleOrgPolicy = policies
|
||||||
|
.filter(p => p.enabled && p.type === PolicyType.SingleOrg)
|
||||||
|
.map(p => p.organizationId);
|
||||||
|
|
||||||
|
this.singleOrgPolicyBlock = orgs.some(org =>
|
||||||
|
org.type !== OrganizationUserType.Owner &&
|
||||||
|
org.type !== OrganizationUserType.Admin &&
|
||||||
|
org.status !== OrganizationUserStatusType.Invited &&
|
||||||
|
orgsWithSingleOrgPolicy.includes(org.id));
|
||||||
|
|
||||||
if (this.singleOrgPolicyBlock) {
|
if (this.singleOrgPolicyBlock) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user