mirror of
https://github.com/bitwarden/jslib
synced 2025-12-15 07:43:45 +00:00
Roll back organizationId and collectionId's if ciphers fail to be moved (#699)
This commit is contained in:
@@ -657,7 +657,15 @@ export class CipherService implements CipherServiceAbstraction {
|
|||||||
}
|
}
|
||||||
await Promise.all(promises);
|
await Promise.all(promises);
|
||||||
const request = new CipherBulkShareRequest(encCiphers, collectionIds);
|
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();
|
const userId = await this.stateService.getUserId();
|
||||||
await this.upsert(encCiphers.map((c) => c.toCipherData(userId)));
|
await this.upsert(encCiphers.map((c) => c.toCipherData(userId)));
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user