-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
48 additions
and
0 deletions.
There are no files selected for viewing
40 changes: 40 additions & 0 deletions
40
...console/services/organization-authorization/default-organization-authorization.service.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { map, Observable } from "rxjs"; | ||
|
||
import { OrganizationUserType } from "@bitwarden/common/admin-console/enums"; | ||
import { Organization } from "@bitwarden/common/admin-console/models/domain/organization"; | ||
import { FeatureFlag } from "@bitwarden/common/enums/feature-flag.enum"; | ||
import { ConfigService } from "@bitwarden/common/platform/abstractions/config/config.service"; | ||
|
||
import { OrganizationAuthorizationService } from "./organization-authorization.service"; | ||
|
||
export class DefaultOrganizationAuthorizationService implements OrganizationAuthorizationService { | ||
constructor(private configService: ConfigService) {} | ||
|
||
canExport(org: Organization): Observable<boolean> { | ||
return this.configService | ||
.getFeatureFlag$(FeatureFlag.PM11360RemoveProviderExportPermission) | ||
.pipe( | ||
map((featureFlag) => { | ||
if (!featureFlag && org.isProviderUser) { | ||
return true; | ||
} | ||
|
||
return ( | ||
org.type === OrganizationUserType.Owner || | ||
org.type === OrganizationUserType.Admin || | ||
org.permissions.accessImportExport | ||
); | ||
}), | ||
); | ||
} | ||
|
||
canImport(org: Organization) { | ||
return ( | ||
org.isProviderUser || | ||
org.type === OrganizationUserType.Owner || | ||
org.type === OrganizationUserType.Admin || | ||
org.permissions.accessImportExport || | ||
org.canCreateNewCollections // To allow users to create collections and then import items into them | ||
); | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
...c/admin-console/services/organization-authorization/organization-authorization.service.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { Observable } from "rxjs"; | ||
|
||
import { Organization } from "../../models/domain/organization"; | ||
|
||
export abstract class OrganizationAuthorizationService { | ||
canExport: (org: Organization) => Observable<boolean>; | ||
canImport: (org: Organization) => boolean; | ||
} |