1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-06 00:13:28 +00:00

[PM-24433] Update the CLI confirm org-member command to create a default collection (#15917)

* Update the CLI ConfirmCommand to send the DefaultUserCollectionName for default collection creation

* Add "My Items" message to CLI

* Refactor ConfirmCommand to encapsulate default user collection name encryption in a separate method
This commit is contained in:
Rui Tomé
2025-08-08 13:53:27 +01:00
committed by GitHub
parent c5e5417abf
commit a139fb5def
4 changed files with 27 additions and 0 deletions

View File

@@ -1,13 +1,20 @@
// FIXME: Update this file to be type safe and remove this and next line
// @ts-strict-ignore
import { firstValueFrom } from "rxjs";
import {
OrganizationUserApiService,
OrganizationUserConfirmRequest,
} from "@bitwarden/admin-console/common";
import { ApiService } from "@bitwarden/common/abstractions/api.service";
import { FeatureFlag } from "@bitwarden/common/enums/feature-flag.enum";
import { EncryptService } from "@bitwarden/common/key-management/crypto/abstractions/encrypt.service";
import { ConfigService } from "@bitwarden/common/platform/abstractions/config/config.service";
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
import { Utils } from "@bitwarden/common/platform/misc/utils";
import { OrgKey } from "@bitwarden/common/types/key";
import { KeyService } from "@bitwarden/key-management";
import { EncString } from "@bitwarden/sdk-internal";
import { Response } from "../../models/response";
@@ -17,6 +24,8 @@ export class ConfirmCommand {
private keyService: KeyService,
private encryptService: EncryptService,
private organizationUserApiService: OrganizationUserApiService,
private configService: ConfigService,
private i18nService: I18nService,
) {}
async run(object: string, id: string, cmdOptions: Record<string, any>): Promise<Response> {
@@ -60,6 +69,11 @@ export class ConfirmCommand {
const key = await this.encryptService.encapsulateKeyUnsigned(orgKey, publicKey);
const req = new OrganizationUserConfirmRequest();
req.key = key.encryptedString;
if (
await firstValueFrom(this.configService.getFeatureFlag$(FeatureFlag.CreateDefaultLocation))
) {
req.defaultUserCollectionName = await this.getEncryptedDefaultUserCollectionName(orgKey);
}
await this.organizationUserApiService.postOrganizationUserConfirm(
options.organizationId,
id,
@@ -70,6 +84,12 @@ export class ConfirmCommand {
return Response.error(e);
}
}
private async getEncryptedDefaultUserCollectionName(orgKey: OrgKey): Promise<EncString> {
const defaultCollectionName = this.i18nService.t("myItems");
const encrypted = await this.encryptService.encryptString(defaultCollectionName, orgKey);
return encrypted.encryptedString;
}
}
class Options {

View File

@@ -215,5 +215,8 @@
},
"youHaveBeenLoggedOut": {
"message": "You have been logged out."
},
"myItems": {
"message": "My Items"
}
}

View File

@@ -131,6 +131,8 @@ export class OssServeConfigurator {
this.serviceContainer.keyService,
this.serviceContainer.encryptService,
this.serviceContainer.organizationUserApiService,
this.serviceContainer.configService,
this.serviceContainer.i18nService,
);
this.restoreCommand = new RestoreCommand(
this.serviceContainer.cipherService,

View File

@@ -432,6 +432,8 @@ export class VaultProgram extends BaseProgram {
this.serviceContainer.keyService,
this.serviceContainer.encryptService,
this.serviceContainer.organizationUserApiService,
this.serviceContainer.configService,
this.serviceContainer.i18nService,
);
const response = await command.run(object, id, cmd);
this.processResponse(response);