From 5dd722414376034f3a84d2ebe587c77ba6b74754 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rui=20Tom=C3=A9?= <108268980+r-tome@users.noreply.github.com> Date: Fri, 24 May 2024 11:20:51 +0100 Subject: [PATCH] [AC-2328] Add a Bulk OrganizationUsersController.GetResetPasswordDetails endpoint (#9140) * [AC-2302] Move organization-auth-request.service to bit-common folder * [AC-2302] Rename organization-auth-request.service to organization-auth-request-api.service * [AC-2302] Move logic from component to organization-auth-request.service * [AC-2302] Fix import path in OrganizationAuthRequestService * [AC-2302] Move imports to OrganizationsModule and delete unused CoreOrganizationModule * [AC-2302] Move the call to get userResetPasswordDetails into OrganizationAuthRequestService * [AC-2302] Remove @Injectable() and manually configure dependencies * [AC-2302] Add OrganizationAuthRequestService unit tests first draft * [AC-2302] Refactor device-approvals.component.ts to remove unused imports * [AC-2302] Set up jest on bit-common and add unit tests for OrganizationAuthRequestService * [AC-2302] Add bit-common to jest.config.js * [AC-2302] Update organizations.module.ts to include safeProviders declared in variable * [AC-2302] Remove services and views folders from bit-common * [AC-2302] Define path mapping * Adjust an import path The import path of `PendingAuthRequestView` in `OrganizationAuthRequestApiService` was pointing to the wrong place. I think this file was just recently moved, and the import didn't get updated. * Get paths working * Fix import * Update jest config to use ts-jest adn jsdom * Copy-paste path mappings from bit-web * Remove unnecessary test setup file * Undo unnecessary change * Fix remaining path mappings * Remove Bitwarden License mapping from OSS code * Fix bit-web so it uses its own tsconfig * Fix import path * Remove web-bit entrypoint from OSS tsconfig * Make DeviceApprovalsComponent standalone * Remove organization-auth-request-api.service export * Remove OrganizationsRoutingModule from DeviceApprovalsComponent imports * Remove CoreOrganizationModule from OrganizationsModule imports * Remove NoItemsModule from OrganizationsModule imports * Use ApiService from JslibServicesModule * Update providers in device-approvals.component.ts * Add method to retrieve reset password details for multiple organization users * Add organizationUserId property to OrganizationUserResetPasswordDetailsResponse class * Rename ResetPasswordDetails to AccountRecoveryDetails --------- Co-authored-by: Addison Beck Co-authored-by: Thomas Rittson --- .../organization-user/organization-user.service.ts | 10 ++++++++++ .../responses/organization-user.response.ts | 2 ++ .../organization-user.service.implementation.ts | 14 ++++++++++++++ 3 files changed, 26 insertions(+) diff --git a/libs/common/src/admin-console/abstractions/organization-user/organization-user.service.ts b/libs/common/src/admin-console/abstractions/organization-user/organization-user.service.ts index d69955c7d0f..7058be08037 100644 --- a/libs/common/src/admin-console/abstractions/organization-user/organization-user.service.ts +++ b/libs/common/src/admin-console/abstractions/organization-user/organization-user.service.ts @@ -66,6 +66,16 @@ export abstract class OrganizationUserService { id: string, ): Promise; + /** + * Retrieve reset password details for many organization users + * @param organizationId - Identifier for the organization + * @param ids - A list of organization user identifiers + */ + abstract getManyOrganizationUserAccountRecoveryDetails( + organizationId: string, + ids: string[], + ): Promise>; + /** * Create new organization user invite(s) for the specified organization * @param organizationId - Identifier for the organization diff --git a/libs/common/src/admin-console/abstractions/organization-user/responses/organization-user.response.ts b/libs/common/src/admin-console/abstractions/organization-user/responses/organization-user.response.ts index 5fb7844793f..ccda2a564b6 100644 --- a/libs/common/src/admin-console/abstractions/organization-user/responses/organization-user.response.ts +++ b/libs/common/src/admin-console/abstractions/organization-user/responses/organization-user.response.ts @@ -70,6 +70,7 @@ export class OrganizationUserDetailsResponse extends OrganizationUserResponse { } export class OrganizationUserResetPasswordDetailsResponse extends BaseResponse { + organizationUserId: string; kdf: KdfType; kdfIterations: number; kdfMemory?: number; @@ -79,6 +80,7 @@ export class OrganizationUserResetPasswordDetailsResponse extends BaseResponse { constructor(response: any) { super(response); + this.organizationUserId = this.getResponseProperty("OrganizationUserId"); this.kdf = this.getResponseProperty("Kdf"); this.kdfIterations = this.getResponseProperty("KdfIterations"); this.kdfMemory = this.getResponseProperty("KdfMemory"); diff --git a/libs/common/src/admin-console/services/organization-user/organization-user.service.implementation.ts b/libs/common/src/admin-console/services/organization-user/organization-user.service.implementation.ts index e3f85e274d2..b66805a20b9 100644 --- a/libs/common/src/admin-console/services/organization-user/organization-user.service.implementation.ts +++ b/libs/common/src/admin-console/services/organization-user/organization-user.service.implementation.ts @@ -98,6 +98,20 @@ export class OrganizationUserServiceImplementation implements OrganizationUserSe return new OrganizationUserResetPasswordDetailsResponse(r); } + async getManyOrganizationUserAccountRecoveryDetails( + organizationId: string, + ids: string[], + ): Promise> { + const r = await this.apiService.send( + "POST", + "/organizations/" + organizationId + "/users/account-recovery-details", + new OrganizationUserBulkRequest(ids), + true, + true, + ); + return new ListResponse(r, OrganizationUserResetPasswordDetailsResponse); + } + postOrganizationUserInvite( organizationId: string, request: OrganizationUserInviteRequest,