mirror of
https://github.com/bitwarden/browser
synced 2025-12-15 15:53:27 +00:00
[PM-11404] Account Management: Prevent a verified user from purging their vault (#11411)
* Update AccountService to include a method for setting the managedByOrganizationId * Update AccountComponent to conditionally show the purgeVault button based on a feature flag and if the user is managed by an organization * Add missing method to FakeAccountService * Remove the setAccountManagedByOrganizationId method from the AccountService abstract class. * Refactor AccountComponent to use OrganizationService to check for managing organization * Rename managesActiveUser to userIsManagedByOrganization * Refactor userIsManagedByOrganization property to be non-nullable in organization data and response models * Refactor organization.data.spec.ts to include non-nullable userIsManagedByOrganization property
This commit is contained in:
@@ -57,6 +57,7 @@ describe("ORGANIZATIONS state", () => {
|
||||
limitCollectionCreationDeletion: false,
|
||||
allowAdminAccessToAllCollectionItems: false,
|
||||
familySponsorshipLastSyncDate: new Date(),
|
||||
userIsManagedByOrganization: false,
|
||||
},
|
||||
};
|
||||
const result = sut.deserializer(JSON.parse(JSON.stringify(expectedResult)));
|
||||
|
||||
@@ -57,6 +57,7 @@ export class OrganizationData {
|
||||
// Deprecated: https://bitwarden.atlassian.net/browse/PM-10863
|
||||
limitCollectionCreationDeletion: boolean;
|
||||
allowAdminAccessToAllCollectionItems: boolean;
|
||||
userIsManagedByOrganization: boolean;
|
||||
|
||||
constructor(
|
||||
response?: ProfileOrganizationResponse,
|
||||
@@ -118,6 +119,7 @@ export class OrganizationData {
|
||||
// Deprecated: https://bitwarden.atlassian.net/browse/PM-10863
|
||||
this.limitCollectionCreationDeletion = response.limitCollectionCreationDeletion;
|
||||
this.allowAdminAccessToAllCollectionItems = response.allowAdminAccessToAllCollectionItems;
|
||||
this.userIsManagedByOrganization = response.userIsManagedByOrganization;
|
||||
|
||||
this.isMember = options.isMember;
|
||||
this.isProviderUser = options.isProviderUser;
|
||||
|
||||
@@ -77,6 +77,12 @@ export class Organization {
|
||||
* Refers to the ability for an owner/admin to access all collection items, regardless of assigned collections
|
||||
*/
|
||||
allowAdminAccessToAllCollectionItems: boolean;
|
||||
/**
|
||||
* Indicates if this organization manages the user.
|
||||
* A user is considered managed by an organization if their email domain
|
||||
* matches one of the verified domains of that organization, and the user is a member of it.
|
||||
*/
|
||||
userIsManagedByOrganization: boolean;
|
||||
|
||||
constructor(obj?: OrganizationData) {
|
||||
if (obj == null) {
|
||||
@@ -134,6 +140,7 @@ export class Organization {
|
||||
// Deprecated: https://bitwarden.atlassian.net/browse/PM-10863
|
||||
this.limitCollectionCreationDeletion = obj.limitCollectionCreationDeletion;
|
||||
this.allowAdminAccessToAllCollectionItems = obj.allowAdminAccessToAllCollectionItems;
|
||||
this.userIsManagedByOrganization = obj.userIsManagedByOrganization;
|
||||
}
|
||||
|
||||
get canAccess() {
|
||||
|
||||
@@ -54,6 +54,7 @@ export class ProfileOrganizationResponse extends BaseResponse {
|
||||
// Deprecated: https://bitwarden.atlassian.net/browse/PM-10863
|
||||
limitCollectionCreationDeletion: boolean;
|
||||
allowAdminAccessToAllCollectionItems: boolean;
|
||||
userIsManagedByOrganization: boolean;
|
||||
|
||||
constructor(response: any) {
|
||||
super(response);
|
||||
@@ -121,5 +122,6 @@ export class ProfileOrganizationResponse extends BaseResponse {
|
||||
this.allowAdminAccessToAllCollectionItems = this.getResponseProperty(
|
||||
"AllowAdminAccessToAllCollectionItems",
|
||||
);
|
||||
this.userIsManagedByOrganization = this.getResponseProperty("UserIsManagedByOrganization");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user