mirror of
https://github.com/bitwarden/jslib
synced 2025-12-23 11:43:51 +00:00
Feature/split manage collections permission (#504)
* Split manage collections permissions * Convert camel to pascal case for element id -> name
This commit is contained in:
@@ -5,8 +5,21 @@ export class PermissionsApi extends BaseResponse {
|
||||
accessEventLogs: boolean;
|
||||
accessImportExport: boolean;
|
||||
accessReports: boolean;
|
||||
/**
|
||||
* @deprecated Sep 29 2021: This permission has been split out to `createNewCollections`, `editAnyCollection`, and
|
||||
* `deleteAnyCollection`. It exists here for backwards compatibility with Server versions <= 1.43.0
|
||||
*/
|
||||
manageAllCollections: boolean;
|
||||
createNewCollections: boolean;
|
||||
editAnyCollection: boolean;
|
||||
deleteAnyCollection: boolean;
|
||||
/**
|
||||
* @deprecated Sep 29 2021: This permission has been split out to `editAssignedCollections` and
|
||||
* `deleteAssignedCollections`. It exists here for backwards compatibility with Server versions <= 1.43.0
|
||||
*/
|
||||
manageAssignedCollections: boolean;
|
||||
editAssignedCollections: boolean;
|
||||
deleteAssignedCollections: boolean;
|
||||
manageCiphers: boolean;
|
||||
manageGroups: boolean;
|
||||
manageSso: boolean;
|
||||
@@ -23,8 +36,17 @@ export class PermissionsApi extends BaseResponse {
|
||||
this.accessEventLogs = this.getResponseProperty('AccessEventLogs');
|
||||
this.accessImportExport = this.getResponseProperty('AccessImportExport');
|
||||
this.accessReports = this.getResponseProperty('AccessReports');
|
||||
|
||||
// For backwards compatibility with Server <= 1.43.0
|
||||
this.manageAllCollections = this.getResponseProperty('ManageAllCollections');
|
||||
this.manageAssignedCollections = this.getResponseProperty('ManageAssignedCollections');
|
||||
|
||||
this.createNewCollections = this.getResponseProperty('CreateNewCollections');
|
||||
this.editAnyCollection = this.getResponseProperty('EditAnyCollection');
|
||||
this.deleteAnyCollection = this.getResponseProperty('DeleteAnyCollection');
|
||||
this.editAssignedCollections = this.getResponseProperty('EditAssignedCollections');
|
||||
this.deleteAssignedCollections = this.getResponseProperty('DeleteAssignedCollections');
|
||||
|
||||
this.manageCiphers = this.getResponseProperty('ManageCiphers');
|
||||
this.manageGroups = this.getResponseProperty('ManageGroups');
|
||||
this.manageSso = this.getResponseProperty('ManageSso');
|
||||
|
||||
@@ -108,12 +108,32 @@ export class Organization {
|
||||
return this.isAdmin || this.permissions.accessReports;
|
||||
}
|
||||
|
||||
get canManageAllCollections() {
|
||||
return this.isAdmin || this.permissions.manageAllCollections;
|
||||
get canCreateNewCollections() {
|
||||
return this.isAdmin || (this.permissions.createNewCollections ?? this.permissions.manageAllCollections);
|
||||
}
|
||||
|
||||
get canManageAssignedCollections() {
|
||||
return this.isManager || this.permissions.manageAssignedCollections;
|
||||
get canEditAnyCollection() {
|
||||
return this.isAdmin || (this.permissions.editAnyCollection ?? this.permissions.manageAllCollections);
|
||||
}
|
||||
|
||||
get canDeleteAnyCollection() {
|
||||
return this.isAdmin || (this.permissions.deleteAnyCollection ?? this.permissions.manageAllCollections);
|
||||
}
|
||||
|
||||
get canViewAllCollections() {
|
||||
return this.canEditAnyCollection || this.canDeleteAnyCollection;
|
||||
}
|
||||
|
||||
get canEditAssignedCollections() {
|
||||
return this.isManager || (this.permissions.deleteAssignedCollections ?? this.permissions.manageAssignedCollections);
|
||||
}
|
||||
|
||||
get canDeleteAssignedCollections() {
|
||||
return this.isManager || (this.permissions.deleteAssignedCollections ?? this.permissions.manageAssignedCollections);
|
||||
}
|
||||
|
||||
get canViewAssignedCollections() {
|
||||
return this.canDeleteAssignedCollections || this.canEditAssignedCollections;
|
||||
}
|
||||
|
||||
get canManageGroups() {
|
||||
|
||||
Reference in New Issue
Block a user