mirror of
https://github.com/bitwarden/browser
synced 2025-12-11 22:03:36 +00:00
[PM-26096] Bugfix: Decryption errors for folders prevent vault access (#16796)
* Handle scenario where folders fail to decrypt
* Add comment explaining the folderViews$ filter check
(cherry picked from commit 4d2106a7c0)
This commit is contained in:
@@ -272,11 +272,16 @@ export class FolderService implements InternalFolderServiceAbstraction {
|
|||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
const decryptFolderPromises = folders.map((f) =>
|
const decryptFolderPromises = folders.map(async (f) => {
|
||||||
f.decryptWithKey(userKey, this.encryptService),
|
try {
|
||||||
);
|
return await f.decryptWithKey(userKey, this.encryptService);
|
||||||
const decryptedFolders = await Promise.all(decryptFolderPromises);
|
} catch {
|
||||||
decryptedFolders.sort(Utils.getSortFunction(this.i18nService, "name"));
|
return null;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
const decryptedFolders = (await Promise.all(decryptFolderPromises))
|
||||||
|
.filter((p) => p !== null)
|
||||||
|
.sort(Utils.getSortFunction(this.i18nService, "name"));
|
||||||
|
|
||||||
const noneFolder = new FolderView();
|
const noneFolder = new FolderView();
|
||||||
noneFolder.name = this.i18nService.t("noneFolder");
|
noneFolder.name = this.i18nService.t("noneFolder");
|
||||||
|
|||||||
@@ -59,9 +59,12 @@ export class DefaultCipherFormConfigService implements CipherFormConfigService {
|
|||||||
this.organizationDataOwnershipDisabled$,
|
this.organizationDataOwnershipDisabled$,
|
||||||
this.folderService.folders$(activeUserId).pipe(
|
this.folderService.folders$(activeUserId).pipe(
|
||||||
switchMap((f) =>
|
switchMap((f) =>
|
||||||
this.folderService.folderViews$(activeUserId).pipe(
|
this.folderService
|
||||||
filter((d) => d.length - 1 === f.length), // -1 for "No Folder" in folderViews$
|
.folderViews$(activeUserId)
|
||||||
),
|
// Ensure the folders have decrypted. f.length === 0 indicates we don't have any
|
||||||
|
// folders to wait for, and d.length > 0 indicates that `folderViews` has emitted the
|
||||||
|
// array, which includes the "No Folder" default folder.
|
||||||
|
.pipe(filter((d) => d.length > 0 || f.length === 0)),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
this.getCipher(activeUserId, cipherId),
|
this.getCipher(activeUserId, cipherId),
|
||||||
|
|||||||
Reference in New Issue
Block a user