1
0
mirror of https://github.com/bitwarden/jslib synced 2025-12-06 00:03:29 +00:00

Roll back organizationId and collectionId's if ciphers fail to be moved (#699)

This commit is contained in:
Robyn MacCallum
2022-03-02 08:11:34 -05:00
committed by GitHub
parent e47eb5e74f
commit 8f5f694a1e

View File

@@ -657,7 +657,15 @@ export class CipherService implements CipherServiceAbstraction {
}
await Promise.all(promises);
const request = new CipherBulkShareRequest(encCiphers, collectionIds);
await this.apiService.putShareCiphers(request);
try {
await this.apiService.putShareCiphers(request);
} catch (e) {
for (const cipher of ciphers) {
cipher.organizationId = null;
cipher.collectionIds = null;
}
throw e;
}
const userId = await this.stateService.getUserId();
await this.upsert(encCiphers.map((c) => c.toCipherData(userId)));
}