1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-06 00:13:28 +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:
Nik Gilmore
2025-10-09 10:46:20 -07:00
parent cd6fce0ec0
commit f3af6a813a
2 changed files with 16 additions and 8 deletions

View File

@@ -272,11 +272,16 @@ export class FolderService implements InternalFolderServiceAbstraction {
return [];
}
const decryptFolderPromises = folders.map((f) =>
f.decryptWithKey(userKey, this.encryptService),
);
const decryptedFolders = await Promise.all(decryptFolderPromises);
decryptedFolders.sort(Utils.getSortFunction(this.i18nService, "name"));
const decryptFolderPromises = folders.map(async (f) => {
try {
return await f.decryptWithKey(userKey, this.encryptService);
} catch {
return null;
}
});
const decryptedFolders = (await Promise.all(decryptFolderPromises))
.filter((p) => p !== null)
.sort(Utils.getSortFunction(this.i18nService, "name"));
const noneFolder = new FolderView();
noneFolder.name = this.i18nService.t("noneFolder");

View File

@@ -59,9 +59,12 @@ export class DefaultCipherFormConfigService implements CipherFormConfigService {
this.organizationDataOwnershipDisabled$,
this.folderService.folders$(activeUserId).pipe(
switchMap((f) =>
this.folderService.folderViews$(activeUserId).pipe(
filter((d) => d.length - 1 === f.length), // -1 for "No Folder" in folderViews$
),
this.folderService
.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),