1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-18 17:23:37 +00:00

Merge remote-tracking branch 'origin/ac/ac-1139/deprecate-custom-collection-perm-eliykat' into ac/ac-1139/deprecate-custom-collection-perm

This commit is contained in:
Rui Tome
2023-11-27 13:33:00 +00:00
3 changed files with 22 additions and 2 deletions

View File

@@ -622,7 +622,7 @@ import { AbstractThemingService } from "./theming/theming.service.abstraction";
{
provide: OrganizationServiceAbstraction,
useClass: OrganizationService,
deps: [StateServiceAbstraction],
deps: [StateServiceAbstraction, ConfigServiceAbstraction],
},
{
provide: InternalOrganizationServiceAbstraction,

View File

@@ -187,6 +187,7 @@ export class Organization {
/**
* @deprecated
* This is deprecated with the introduction of Flexible Collections.
* This will always return false if FlexibleCollections flag is on.
*/
get canEditAssignedCollections() {
return this.isManager || this.permissions.editAssignedCollections;
@@ -195,6 +196,7 @@ export class Organization {
/**
* @deprecated
* This is deprecated with the introduction of Flexible Collections.
* This will always return false if FlexibleCollections flag is on.
*/
get canDeleteAssignedCollections() {
return this.isManager || this.permissions.deleteAssignedCollections;
@@ -203,6 +205,7 @@ export class Organization {
/**
* @deprecated
* This is deprecated with the introduction of Flexible Collections.
* This will always return false if FlexibleCollections flag is on.
*/
get canViewAssignedCollections() {
return this.canDeleteAssignedCollections || this.canEditAssignedCollections;

View File

@@ -1,10 +1,13 @@
import { BehaviorSubject, concatMap, map, Observable } from "rxjs";
import { FeatureFlag } from "../../../enums/feature-flag.enum";
import { ConfigServiceAbstraction } from "../../../platform/abstractions/config/config.service.abstraction";
import { StateService } from "../../../platform/abstractions/state.service";
import {
InternalOrganizationServiceAbstraction,
isMember,
} from "../../abstractions/organization/organization.service.abstraction";
import { OrganizationUserType } from "../../enums";
import { OrganizationData } from "../../models/data/organization.data";
import { Organization } from "../../models/domain/organization";
@@ -14,7 +17,7 @@ export class OrganizationService implements InternalOrganizationServiceAbstracti
organizations$ = this._organizations.asObservable();
memberOrganizations$ = this.organizations$.pipe(map((orgs) => orgs.filter(isMember)));
constructor(private stateService: StateService) {
constructor(private stateService: StateService, private configService: ConfigServiceAbstraction) {
this.stateService.activeAccountUnlocked$
.pipe(
concatMap(async (unlocked) => {
@@ -103,6 +106,20 @@ export class OrganizationService implements InternalOrganizationServiceAbstracti
}
async replace(organizations: { [id: string]: OrganizationData }) {
// If Flexible Collections is enabled, treat Managers as Users and ignore deprecated permissions
if (await this.configService.getFeatureFlag(FeatureFlag.FlexibleCollections)) {
Object.values(organizations).forEach((o) => {
if (o.type === OrganizationUserType.Manager) {
o.type = OrganizationUserType.User;
}
if (o.permissions != null) {
o.permissions.editAssignedCollections = false;
o.permissions.deleteAssignedCollections = false;
}
});
}
await this.stateService.setOrganizations(organizations);
this.updateObservables(organizations);
}