1
0
mirror of https://github.com/bitwarden/browser synced 2025-01-14 03:19:54 +01: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
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

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)));
}