MCPcopy Create free account
hub / github.com/bitwarden/clients / editCipherCollections

Method editCipherCollections

apps/cli/src/commands/edit.command.ts:210–238  ·  view source on GitHub ↗
(id: string, req: string[])

Source from the content-addressed store, hash-verified

208 }
209
210 private async editCipherCollections(id: string, req: string[]) {
211 const activeUserId = await firstValueFrom(this.accountService.activeAccount$.pipe(getUserId));
212
213 const cipher = await this.cipherService.get(id, activeUserId);
214 if (cipher == null) {
215 return Response.notFound();
216 }
217 if (cipher.organizationId == null) {
218 return Response.badRequest(
219 "Item does not belong to an organization. Consider moving it first.",
220 );
221 }
222 if (!cipher.viewPassword) {
223 return Response.noEditPermission();
224 }
225
226 cipher.collectionIds = req;
227 try {
228 const updatedCipher = await this.cipherService.saveCollectionsWithServer(
229 cipher,
230 activeUserId,
231 );
232 const decCipher = await this.cipherService.decrypt(updatedCipher, activeUserId);
233 const res = new CipherResponse(decCipher);
234 return Response.success(res);
235 } catch (e) {
236 return Response.error(e);
237 }
238 }
239
240 private async editFolder(id: string, req: FolderExport) {
241 const activeUserId = await firstValueFrom(this.accountService.activeAccount$.pipe(getUserId));

Callers 1

runMethod · 0.95

Calls 8

notFoundMethod · 0.80
badRequestMethod · 0.80
noEditPermissionMethod · 0.80
successMethod · 0.80
errorMethod · 0.65
getMethod · 0.45
decryptMethod · 0.45

Tested by

no test coverage detected