mirror of
https://github.com/bitwarden/browser
synced 2025-12-12 22:33:35 +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:
@@ -1,13 +1,20 @@
|
|||||||
// FIXME: Update this file to be type safe and remove this and next line
|
// FIXME: Update this file to be type safe and remove this and next line
|
||||||
// @ts-strict-ignore
|
// @ts-strict-ignore
|
||||||
|
import { firstValueFrom } from "rxjs";
|
||||||
|
|
||||||
import {
|
import {
|
||||||
OrganizationUserApiService,
|
OrganizationUserApiService,
|
||||||
OrganizationUserConfirmRequest,
|
OrganizationUserConfirmRequest,
|
||||||
} from "@bitwarden/admin-console/common";
|
} from "@bitwarden/admin-console/common";
|
||||||
import { ApiService } from "@bitwarden/common/abstractions/api.service";
|
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 { 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 { Utils } from "@bitwarden/common/platform/misc/utils";
|
||||||
|
import { OrgKey } from "@bitwarden/common/types/key";
|
||||||
import { KeyService } from "@bitwarden/key-management";
|
import { KeyService } from "@bitwarden/key-management";
|
||||||
|
import { EncString } from "@bitwarden/sdk-internal";
|
||||||
|
|
||||||
import { Response } from "../../models/response";
|
import { Response } from "../../models/response";
|
||||||
|
|
||||||
@@ -17,6 +24,8 @@ export class ConfirmCommand {
|
|||||||
private keyService: KeyService,
|
private keyService: KeyService,
|
||||||
private encryptService: EncryptService,
|
private encryptService: EncryptService,
|
||||||
private organizationUserApiService: OrganizationUserApiService,
|
private organizationUserApiService: OrganizationUserApiService,
|
||||||
|
private configService: ConfigService,
|
||||||
|
private i18nService: I18nService,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
async run(object: string, id: string, cmdOptions: Record<string, any>): Promise<Response> {
|
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 key = await this.encryptService.encapsulateKeyUnsigned(orgKey, publicKey);
|
||||||
const req = new OrganizationUserConfirmRequest();
|
const req = new OrganizationUserConfirmRequest();
|
||||||
req.key = key.encryptedString;
|
req.key = key.encryptedString;
|
||||||
|
if (
|
||||||
|
await firstValueFrom(this.configService.getFeatureFlag$(FeatureFlag.CreateDefaultLocation))
|
||||||
|
) {
|
||||||
|
req.defaultUserCollectionName = await this.getEncryptedDefaultUserCollectionName(orgKey);
|
||||||
|
}
|
||||||
await this.organizationUserApiService.postOrganizationUserConfirm(
|
await this.organizationUserApiService.postOrganizationUserConfirm(
|
||||||
options.organizationId,
|
options.organizationId,
|
||||||
id,
|
id,
|
||||||
@@ -70,6 +84,12 @@ export class ConfirmCommand {
|
|||||||
return Response.error(e);
|
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 {
|
class Options {
|
||||||
|
|||||||
@@ -215,5 +215,8 @@
|
|||||||
},
|
},
|
||||||
"youHaveBeenLoggedOut": {
|
"youHaveBeenLoggedOut": {
|
||||||
"message": "You have been logged out."
|
"message": "You have been logged out."
|
||||||
|
},
|
||||||
|
"myItems": {
|
||||||
|
"message": "My Items"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -131,6 +131,8 @@ export class OssServeConfigurator {
|
|||||||
this.serviceContainer.keyService,
|
this.serviceContainer.keyService,
|
||||||
this.serviceContainer.encryptService,
|
this.serviceContainer.encryptService,
|
||||||
this.serviceContainer.organizationUserApiService,
|
this.serviceContainer.organizationUserApiService,
|
||||||
|
this.serviceContainer.configService,
|
||||||
|
this.serviceContainer.i18nService,
|
||||||
);
|
);
|
||||||
this.restoreCommand = new RestoreCommand(
|
this.restoreCommand = new RestoreCommand(
|
||||||
this.serviceContainer.cipherService,
|
this.serviceContainer.cipherService,
|
||||||
|
|||||||
@@ -432,6 +432,8 @@ export class VaultProgram extends BaseProgram {
|
|||||||
this.serviceContainer.keyService,
|
this.serviceContainer.keyService,
|
||||||
this.serviceContainer.encryptService,
|
this.serviceContainer.encryptService,
|
||||||
this.serviceContainer.organizationUserApiService,
|
this.serviceContainer.organizationUserApiService,
|
||||||
|
this.serviceContainer.configService,
|
||||||
|
this.serviceContainer.i18nService,
|
||||||
);
|
);
|
||||||
const response = await command.run(object, id, cmd);
|
const response = await command.run(object, id, cmd);
|
||||||
this.processResponse(response);
|
this.processResponse(response);
|
||||||
|
|||||||
Reference in New Issue
Block a user