1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-15 15:53:27 +00:00

org collection edit command

This commit is contained in:
Kyle Spearrin
2019-10-01 11:16:24 -04:00
parent abcd43b4ba
commit 04df76e83f
3 changed files with 67 additions and 5 deletions

View File

@@ -25,6 +25,8 @@ import { OrganizationCollectionRequest } from '../models/request/organizationCol
import { CliUtils } from '../utils';
import { Utils } from 'jslib/misc/utils';
export class CreateCommand {
constructor(private cipherService: CipherService, private folderService: FolderService,
private userService: UserService, private cryptoService: CryptoService,
@@ -57,7 +59,7 @@ export class CreateCommand {
case 'folder':
return await this.createFolder(req);
case 'org-collection':
return await this.createOrganizationCollection(req);
return await this.createOrganizationCollection(req, cmd);
default:
return Response.badRequest('Unknown object.');
}
@@ -130,7 +132,16 @@ export class CreateCommand {
}
}
private async createOrganizationCollection(req: OrganizationCollectionRequest) {
private async createOrganizationCollection(req: OrganizationCollectionRequest, cmd: program.Command) {
if (cmd.organizationid == null || cmd.organizationid === '') {
return Response.badRequest('--organizationid <organizationid> required.');
}
if (!Utils.isGuid(cmd.organizationid)) {
return Response.error('`' + cmd.organizationid + '` is not a GUID.');
}
if (cmd.organizationid !== req.organizationId) {
return Response.error('--organizationid <organizationid> does not match request object.');
}
try {
const orgKey = await this.cryptoService.getOrgKey(req.organizationId);
if (orgKey == null) {