1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-18 01:03:35 +00:00

edit item collections

This commit is contained in:
Kyle Spearrin
2018-10-23 17:31:59 -04:00
parent 8f857988ca
commit e0b9d84ad5
5 changed files with 29 additions and 1 deletions

View File

@@ -39,6 +39,8 @@ export class EditCommand {
switch (object.toLowerCase()) {
case 'item':
return await this.editCipher(id, req);
case 'item-collections':
return await this.editCipherCollections(id, req);
case 'folder':
return await this.editFolder(id, req);
default:
@@ -66,6 +68,24 @@ export class EditCommand {
}
}
private async editCipherCollections(id: string, req: string[]) {
const cipher = await this.cipherService.get(id);
if (cipher == null) {
return Response.notFound();
}
cipher.collectionIds = req;
try {
await this.cipherService.saveCollectionsWithServer(cipher);
const updatedCipher = await this.cipherService.get(cipher.id);
const decCipher = await updatedCipher.decrypt();
const res = new CipherResponse(decCipher);
return Response.success(res);
} catch (e) {
return Response.error(e);
}
}
private async editFolder(id: string, req: Folder) {
const folder = await this.folderService.get(id);
if (folder == null) {

View File

@@ -364,6 +364,9 @@ export class GetCommand {
case 'collection':
template = Collection.template();
break;
case 'item-collections':
template = ['collection-id1', 'collection-id2'];
break;
default:
return Response.badRequest('Unknown template object.');
}