diff --git a/apps/web/src/app/admin-console/organizations/members/components/member-dialog/member-dialog.component.html b/apps/web/src/app/admin-console/organizations/members/components/member-dialog/member-dialog.component.html index 2c5daf93c6..b281272747 100644 --- a/apps/web/src/app/admin-console/organizations/members/components/member-dialog/member-dialog.component.html +++ b/apps/web/src/app/admin-console/organizations/members/components/member-dialog/member-dialog.component.html @@ -264,6 +264,16 @@ + + diff --git a/apps/web/src/app/admin-console/organizations/members/members.component.ts b/apps/web/src/app/admin-console/organizations/members/members.component.ts index 394c900f8d..e61348e384 100644 --- a/apps/web/src/app/admin-console/organizations/members/members.component.ts +++ b/apps/web/src/app/admin-console/organizations/members/members.component.ts @@ -518,6 +518,7 @@ export class MembersComponent extends BaseMembersComponent isOnSecretsManagerStandalone: this.orgIsOnSecretsManagerStandalone, initialTab: initialTab, numConfirmedMembers: this.dataSource.confirmedUserCount, + managedByOrganization: user?.managedByOrganization, }, }); @@ -725,6 +726,40 @@ export class MembersComponent extends BaseMembersComponent return true; } + async deleteUser(user: OrganizationUserView) { + const confirmed = await this.dialogService.openSimpleDialog({ + title: { + key: "deleteOrganizationUser", + placeholders: [this.userNamePipe.transform(user)], + }, + content: { key: "deleteOrganizationUserWarning" }, + type: "warning", + acceptButtonText: { key: "delete" }, + cancelButtonText: { key: "cancel" }, + }); + + if (!confirmed) { + return false; + } + + this.actionPromise = this.organizationUserApiService.deleteOrganizationUser( + this.organization.id, + user.id, + ); + try { + await this.actionPromise; + this.toastService.showToast({ + variant: "success", + title: null, + message: this.i18nService.t("organizationUserDeleted", this.userNamePipe.transform(user)), + }); + this.dataSource.removeUser(user); + } catch (e) { + this.validationService.showError(e); + } + this.actionPromise = null; + } + private async noMasterPasswordConfirmationDialog(user: OrganizationUserView) { return this.dialogService.openSimpleDialog({ title: { diff --git a/apps/web/src/locales/en/messages.json b/apps/web/src/locales/en/messages.json index 986648e5c1..7e441ae4ba 100644 --- a/apps/web/src/locales/en/messages.json +++ b/apps/web/src/locales/en/messages.json @@ -9554,5 +9554,31 @@ }, "single-org-revoked-user-warning": { "message": "Non-compliant members will be revoked. Administrators can restore members once they leave all other organizations." + }, + "deleteOrganizationUser": { + "message": "Delete $NAME$", + "placeholders": { + "name": { + "content": "$1", + "example": "John Doe" + }, + "description": "Title for the delete organization user dialog" + } + }, + "deleteOrganizationUserWarning": { + "message": "When a member is deleted, their Bitwarden account and individual vault data will be permanently deleted. Collection data will remain in the organization. To reinstate them they must create an account and be onboarded again.", + "description": "Warning for the delete organization user dialog" + }, + "organizationUserDeleted": { + "message": "Deleted $NAME$", + "placeholders": { + "name": { + "content": "$1", + "example": "John Doe" + } + } + }, + "organizationUserDeletedDesc": { + "message": "The user was removed from the organization and all associated user data has been deleted." } } diff --git a/libs/admin-console/src/common/organization-user/abstractions/organization-user-api.service.ts b/libs/admin-console/src/common/organization-user/abstractions/organization-user-api.service.ts index ff7f9c5df6..42cbe1438d 100644 --- a/libs/admin-console/src/common/organization-user/abstractions/organization-user-api.service.ts +++ b/libs/admin-console/src/common/organization-user/abstractions/organization-user-api.service.ts @@ -275,4 +275,11 @@ export abstract class OrganizationUserApiService { organizationId: string, ids: string[], ): Promise>; + + /** + * Remove an organization user's access to the organization and delete their account data + * @param organizationId - Identifier for the organization the user belongs to + * @param id - Organization user identifier + */ + abstract deleteOrganizationUser(organizationId: string, id: string): Promise; } diff --git a/libs/admin-console/src/common/organization-user/services/default-organization-user-api.service.ts b/libs/admin-console/src/common/organization-user/services/default-organization-user-api.service.ts index 6a9911e732..d9e069dc93 100644 --- a/libs/admin-console/src/common/organization-user/services/default-organization-user-api.service.ts +++ b/libs/admin-console/src/common/organization-user/services/default-organization-user-api.service.ts @@ -359,4 +359,14 @@ export class DefaultOrganizationUserApiService implements OrganizationUserApiSer ); return new ListResponse(r, OrganizationUserBulkResponse); } + + deleteOrganizationUser(organizationId: string, id: string): Promise { + return this.apiService.send( + "DELETE", + "/organizations/" + organizationId + "/users/" + id + "/delete-account", + null, + true, + false, + ); + } }