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

Method editCipherCollections

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

Source from the content-addressed store, hash-verified

158 }
159
160 private async editCipherCollections(id: string, req: string[]) {
161 const activeUserId = await firstValueFrom(this.accountService.activeAccount$.pipe(getUserId));
162
163 const cipher = await this.cipherService.get(id, activeUserId);
164 if (cipher == null) {
165 return Response.notFound();
166 }
167 if (cipher.organizationId == null) {
168 return Response.badRequest(
169 "Item does not belong to an organization. Consider moving it first.",
170 );
171 }
172 if (!cipher.viewPassword) {
173 return Response.noEditPermission();
174 }
175
176 cipher.collectionIds = req;
177 try {
178 const updatedCipher = await this.cipherService.saveCollectionsWithServer(
179 cipher,
180 activeUserId,
181 );
182 const decCipher = await this.cipherService.decrypt(updatedCipher, activeUserId);
183 const res = new CipherResponse(decCipher);
184 return Response.success(res);
185 } catch (e) {
186 return Response.error(e);
187 }
188 }
189
190 private async editFolder(id: string, req: FolderExport) {
191 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